{"id":13660670,"url":"https://github.com/jednano/postcss-center","last_synced_at":"2025-07-21T00:34:55.886Z","repository":{"id":35688305,"uuid":"39964882","full_name":"jednano/postcss-center","owner":"jednano","description":"PostCSS plugin to center elements.","archived":false,"fork":false,"pushed_at":"2017-11-02T17:25:46.000Z","size":66,"stargazers_count":42,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-07-11T18:28:42.096Z","etag":null,"topics":["center","postcss","postcss-plugin"],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jednano.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-07-30T18:01:36.000Z","updated_at":"2025-02-27T14:21:33.000Z","dependencies_parsed_at":"2022-09-17T11:12:18.447Z","dependency_job_id":null,"html_url":"https://github.com/jednano/postcss-center","commit_stats":null,"previous_names":["jedmao/postcss-center"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/jednano/postcss-center","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jednano%2Fpostcss-center","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jednano%2Fpostcss-center/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jednano%2Fpostcss-center/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jednano%2Fpostcss-center/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jednano","download_url":"https://codeload.github.com/jednano/postcss-center/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jednano%2Fpostcss-center/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265386079,"owners_count":23756747,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["center","postcss","postcss-plugin"],"created_at":"2024-08-02T05:01:24.370Z","updated_at":"2025-07-21T00:34:55.866Z","avatar_url":"https://github.com/jednano.png","language":"TypeScript","funding_links":[],"categories":["TypeScript"],"sub_categories":[],"readme":"# postcss-center\n\n\u003cimg align=\"right\" width=\"135\" height=\"95\"\n\ttitle=\"Philosopher’s stone, logo of PostCSS\"\n\tsrc=\"http://postcss.github.io/postcss/logo-leftp.png\"\u003e\n\n[![NPM version](http://img.shields.io/npm/v/postcss-center.svg?style=flat)](https://www.npmjs.org/package/postcss-center)\n[![npm license](http://img.shields.io/npm/l/postcss-center.svg?style=flat-square)](https://www.npmjs.org/package/postcss-center)\n[![Travis Build Status](https://img.shields.io/travis/jedmao/postcss-center.svg)](https://travis-ci.org/jedmao/postcss-center)\n[![codecov](https://codecov.io/gh/jedmao/postcss-center/branch/master/graph/badge.svg)](https://codecov.io/gh/jedmao/postcss-center)\n[![Dependency Status](https://gemnasium.com/badges/github.com/jedmao/postcss-center.svg)](https://gemnasium.com/github.com/jedmao/postcss-center)\n\n[![npm](https://nodei.co/npm/postcss-center.svg?downloads=true)](https://nodei.co/npm/postcss-center/)\n\n[PostCSS](https://github.com/postcss/postcss) plugin to center elements.\n\n## Introduction\n\nCentering elements in CSS [isn't exactly straight-forward](http://www.w3.org/Style/Examples/007/center.en.html), but we can change that!\n\n```css\n.foo {\n\ttop: center;\n\tleft: center;\n}\n```\n\nTranspiles into:\n\n```css\n.foo {\n\tposition: absolute;\n\ttop: 50%;\n\tleft: 50%;\n\tmargin-right: -50%;\n\ttransform: translate(-50%, -50%)\n}\n```\n\nOf course, you don't have to include both `top` and `left`:\n\n```css\n.foo {\n\ttop: center;\n}\n```\n\nTranspiles into:\n\n```css\n.foo {\n\tposition: absolute;\n\ttop: 50%;\n\ttransform: translateY(-50%);\n}\n```\n\nOr...\n\n```css\n.foo {\n\tleft: center;\n}\n```\n\nTranspiles into:\n\n```css\n.foo {\n\tposition: absolute;\n\tleft: 50%;\n\tmargin-right: -50%;\n\ttransform: translateX(-50%);\n}\n```\n\nThat's about it!\n\n### Conditions\n\n- If the value of `top` or `left` is not `center` it will be preserved. If both are not `center`, this plugin will do nothing!\n- If the rule already has a `position` it will only be preserved if its value is `relative` or `fixed`. All other values will be replaced with `absolute`.\n- If the rule has a `position` of `relative` or the value of `left` is not `center`, the `margin-right` declaration will not be inserted.\n\n## Installation\n\n```\n$ npm install postcss-center\n```\n\n## Usage\n\n### JavaScript\n\n```js\npostcss([ require('postcss-center') ]);\n```\n\n### TypeScript\n\n```ts\nimport * as postcssCenter from 'postcss-center';\n\npostcss([ postcssCenter ]);\n```\n\n## Options\n\nNone at this time.\n\n## Testing\n\nRun the following command:\n\n```\n$ npm test\n```\n\nThis will build scripts, run tests and generate a code coverage report. Anything less than 100% coverage will throw an error.\n\n### Watching\n\nFor much faster development cycles, run the following commands in 2 separate processes:\n\n```\n$ npm run build:watch\n```\n\nCompiles TypeScript source into the `./dist` folder and watches for changes.\n\n```\n$ npm run watch\n```\n\nRuns the tests in the `./dist` folder and watches for changes.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjednano%2Fpostcss-center","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjednano%2Fpostcss-center","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjednano%2Fpostcss-center/lists"}