Socket
Socket
Sign inDemoInstall

postcss-pxtorem

Package Overview
Dependencies
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

postcss-pxtorem

A CSS post-processor that converts px to rem.


Version published
Weekly downloads
137K
increased by8.71%
Maintainers
1
Weekly downloads
 
Created

What is postcss-pxtorem?

The postcss-pxtorem package is a PostCSS plugin that converts pixel units to rem units in CSS. This is particularly useful for responsive web design, as rem units are relative to the root element's font size, making it easier to scale elements proportionally across different screen sizes.

What are postcss-pxtorem's main functionalities?

Basic Conversion

This configuration converts all pixel values to rem values based on a root font size of 16 pixels. The `propList` option specifies which properties should be converted; in this case, all properties are included.

module.exports = {
  plugins: {
    'postcss-pxtorem': {
      rootValue: 16,
      propList: ['*']
    }
  }
};

Selective Conversion

This configuration converts only the specified properties (font, margin, and padding) from pixels to rems. This allows for more granular control over which CSS properties are affected.

module.exports = {
  plugins: {
    'postcss-pxtorem': {
      rootValue: 16,
      propList: ['font', 'margin', 'padding']
    }
  }
};

Excluding Specific Selectors

This configuration excludes specific selectors (in this case, `.ignore` and `.no-rem`) from the conversion process. This is useful when you want certain elements to retain their pixel values.

module.exports = {
  plugins: {
    'postcss-pxtorem': {
      rootValue: 16,
      propList: ['*'],
      selectorBlackList: ['.ignore', '.no-rem']
    }
  }
};

Other packages similar to postcss-pxtorem

Keywords

FAQs

Package last updated on 20 Jan 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc