# @f/offset-parent

> Find the offset parent of a DOM element

Latest version **1.0.1** (published 2016-03-30) · MIT license · 0 weekly downloads

## Install

```sh
npm install @f/offset-parent
pnpm add @f/offset-parent
yarn add @f/offset-parent
bun add @f/offset-parent
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2016-03-30 |
| First published | 2016-03-30 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Maintainers | f |

## Links

- npm: https://www.npmjs.com/package/@f/offset-parent
- Repository: https://github.com/micro-js/offset-parent
- Homepage: https://github.com/micro-js/offset-parent#readme
- Issues: https://github.com/micro-js/offset-parent/issues
- npm.io page: https://npm.io/package/@f/offset-parent

## Recent versions

- 1.0.1 (latest) — 2016-03-30
- 1.0.0 — 2016-03-30

## README

# offset-parent

[![Build status][travis-image]][travis-url]
[![Git tag][git-image]][git-url]
[![NPM version][npm-image]][npm-url]
[![Code style][standard-image]][standard-url]

Find the offset parent of a DOM element

## Installation

    $ npm install @f/offset-parent

## Usage

The offset parent of a given element is the first parent up the tree that is positioned `absolute`, `relative`, or `fixed`.

```js
var offsetParent = require('@f/offset-parent')

function position (node, placement) {
  var parent = offsetParent(node)

  node.style.left = (parent.offsetWidth / 2) - (node.offsetWidth / 2) + 'px'
  switch (placement) {
    case 'top':
      node.style.top = -node.offsetHeight + 'px'
      break
    case 'bottom':
      node.style.bottom = '0px'
      break
  }
}

```

## API

### offsetParent(node)

- `node` - The DOM node who's offsetParent you want to find

**Returns:** The first node above `node` that is positioned `absolute`, `relative`, or `fixed`.

## License

MIT

[travis-image]: https://img.shields.io/travis/micro-js/offset-parent.svg?style=flat-square
[travis-url]: https://travis-ci.org/micro-js/offset-parent
[git-image]: https://img.shields.io/github/tag/micro-js/offset-parent.svg?style=flat-square
[git-url]: https://github.com/micro-js/offset-parent
[standard-image]: https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-square
[standard-url]: https://github.com/feross/standard
[npm-image]: https://img.shields.io/npm/v/@f/offset-parent.svg?style=flat-square
[npm-url]: https://npmjs.org/package/@f/offset-parent

---
_Source: https://npm.io/package/@f/offset-parent · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
