All Projects → pierreburel → postcss-rem

pierreburel / postcss-rem

Licence: MIT license
PostCSS plugin to use rem units with optional pixel fallback.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to postcss-rem

postcss-relaxed-unit
🍮Postcss-relaxed-unit is a postcss plugin for unit tranformation and make write css easier with custom unit.
Stars: ✭ 44 (+214.29%)
Mutual labels:  postcss, rem
postcss-flexible
🔲 dpr/rem/url transformer for flexible
Stars: ✭ 19 (+35.71%)
Mutual labels:  postcss, rem
react-cli
基于 create-react-app 搭建的前端脚手架
Stars: ✭ 18 (+28.57%)
Mutual labels:  postcss, rem
mobileweb
webpack 5 + postcss 8 构建移动端网站架子
Stars: ✭ 23 (+64.29%)
Mutual labels:  postcss, rem
postcsslayouts
This is the repository for my course, Building a Responsive Single-Page Design with PostCSS on LinkedIn Learning and Lynda.com.
Stars: ✭ 22 (+57.14%)
Mutual labels:  postcss
craft3-webpack5-tailwind2-boilerplate
A real-world boilerplate for Craft CMS 3 projects that leverages Wepback 5, Tailwind 2, PostCSS 8, and has a hot-reload dev environment. Now with dynamic imports, asynchronous chunk loading, and legacy vs modern browser support!
Stars: ✭ 44 (+214.29%)
Mutual labels:  postcss
postcss-styled
PostCSS syntax for parsing styled components
Stars: ✭ 53 (+278.57%)
Mutual labels:  postcss
postcss-prefixwrap
A PostCSS plugin that is used to wrap css styles with a css selector to constrain their affect on parent elements in a page.
Stars: ✭ 54 (+285.71%)
Mutual labels:  postcss
postcss-lazyimagecss
A PostCSS plugin that generates images's CSS width & height properties automatically.
Stars: ✭ 38 (+171.43%)
Mutual labels:  postcss
tailwind-caret-color
Tailwindcss plugin to color caret in input fields
Stars: ✭ 12 (-14.29%)
Mutual labels:  postcss
gulp-boilerplate
Gulp boilerplate
Stars: ✭ 24 (+71.43%)
Mutual labels:  postcss
postcss-windicss
PostCSS integrations for Windi CSS
Stars: ✭ 33 (+135.71%)
Mutual labels:  postcss
postcss-variable-compress
Minifies css variable names
Stars: ✭ 18 (+28.57%)
Mutual labels:  postcss
postcss-redundant-color-vars
⚒️ PostCSS plugin that fixes a bug in safari when using custom properties in certain color declarations.
Stars: ✭ 11 (-21.43%)
Mutual labels:  postcss
antares-front-end
💻 Anatres Project Front-end Implementation. Create projects with clean material-design layouts, to improve user experience with fully responsive and elastic system. Object orientend javascript with Vue components, easy to use css grids, forms, widgets, build system based on Webpack and Grunt, and many more.
Stars: ✭ 35 (+150%)
Mutual labels:  postcss
criteria-of-quality-frontend
Критерии качественной вёрстки (разметка, стилизация, картинки, шрифты, автоматизация и пр.)
Stars: ✭ 26 (+85.71%)
Mutual labels:  postcss
postcss-egyptian-stylesheets
PostCSS plugin for writing Egyptian Style Sheets. Feel free to PR
Stars: ✭ 17 (+21.43%)
Mutual labels:  postcss
postcss-gtk
Processes GTK+ CSS into browser CSS
Stars: ✭ 23 (+64.29%)
Mutual labels:  postcss
injected-css
{:;} CSS in JS
Stars: ✭ 18 (+28.57%)
Mutual labels:  postcss
postcss-font-pack
PostCSS plugin to simplify font declarations by validating only configured font packs are used and adding fallbacks.
Stars: ✭ 18 (+28.57%)
Mutual labels:  postcss

postcss-rem Node.js CI

PostCSS plugin to use rem units with optional pixel fallback. Based on sass-rem.

See also: startijenn-rem, vanilla JavaScript version.

Example

Input

.demo {
  font-size: rem(24px); /* Simple */
  padding: rem(5px 10px); /* Multiple values */
  margin: rem(10px 0.5rem); /* Existing rem */
  border-bottom: rem(1px solid black); /* Multiple mixed values */
  box-shadow: rem(
    0 0 2px #ccc,
    inset 0 0 5px #eee
  ); /* Comma-separated values */
  text-shadow: rem(1px 1px) #eee, rem(-1px) 0 #eee; /* Alternate use */
}

Output

.demo {
  font-size: 1.5rem; /* Simple */
  padding: 0.3125rem 0.625rem; /* Multiple values */
  margin: 0.625rem 0.5rem; /* Existing rem */
  border-bottom: 0.0625rem solid black; /* Multiple mixed values */
  box-shadow: 0 0 0.125rem #ccc, inset 0 0 0.3125rem #eee; /* Comma-separated values */
  text-shadow: 0.0625rem 0.0625rem #eee, -0.0625rem 0 #eee; /* Alternate use */
}

Options

With baseline to 10 (html { font-size: 62.5%; }) and fallback to true:

.demo {
  font-size: 24px;
  font-size: 2.4rem; /* Simple */
  padding: 5px 10px;
  padding: 0.5rem 1rem; /* Multiple values */
  margin: 10px 5px;
  margin: 1rem 0.5rem; /* Existing rem */
  border-bottom: 1px solid black;
  border-bottom: 0.1rem solid black; /* Multiple mixed values */
  box-shadow: 0 0 2px #ccc, inset 0 0 5px #eee;
  box-shadow: 0 0 0.2rem #ccc, inset 0 0 0.5rem #eee; /* Comma-separated values */
  text-shadow: 1px 1px #eee, -1px 0 #eee;
  text-shadow: 0.1rem 0.1rem #eee, -0.1rem 0 #eee; /* Alternate use */
}

With convert to px (for a lt-ie9 only stylesheet for example):

.demo {
  font-size: 24px; /* Simple */
  padding: 5px 10px; /* Multiple values */
  margin: 10px 8px; /* Existing rem */
  border-bottom: 1px solid black; /* Multiple mixed values */
  box-shadow: 0 0 2px #ccc, inset 0 0 5px #eee; /* Comma-separated values */
  text-shadow: 1px 1px #eee, -1px 0 #eee; /* Alternate use */
}

Usage

Install with npm i postcss-rem and use with PostCSS:

postcss([require("postcss-rem")]);

Example with custom options:

postcss([
  require("postcss-rem")({
    name: "to-rem", // Default to 'rem'
    baseline: 10, // Default to 16
    // convert: "px", // Default to 'rem'
    fallback: true, // Default to false
    precision: 6, // Default to 5
  }),
]);

See PostCSS docs for examples for your environment.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].