Giter Site home page Giter Site logo

px-to-rem's Introduction

PX to REM Converter

This Python script is designed to convert all pixel (px) units to relative (rem) units in CSS or SCSS files, and vice versa. It can be used to make your CSS more responsive and scalable.

Features

  • Convert all px units to rem units in a given file.
  • Convert all rem units back to px units.
  • Search for files in subfolders.
  • Ignore specific files and folders.
  • Specify the base pixel size for rem conversion.

Usage

You can run the script from the command line with the following arguments:

  • directory: The directory containing the CSS or SCSS files to convert.
  • --base: The base pixel size for rem conversion. Default is 16.
  • --subfolder: Set this flag to search in subfolders.
  • --css: Set this flag to convert CSS files instead of SCSS files.
  • --revert: Set this flag to convert rem values back to px.
  • --ignore-folder: List of folder paths to ignore.
  • --ignore-file: List of file names to ignore.

Example usage:

python px-to-rem.py ./my-css-directory --base 16 --subfolder --css --revert --ignore-folder ./ignore-this-folder --ignore-file ignore-this-file.css

This will convert all rem units back to px units in all CSS files in ./my-css-directory and its subfolders, except for the files in ./ignore-this-folder and the file named ignore-this-file.css.

Requirements

This script requires Python 3 and the tqdm library for displaying progress. You can install tqdm with pip:

pip install tqdm

Disclaimer

Please make sure to backup your files before running this script, as it will overwrite the original files.

px-to-rem's People

Contributors

mrlappes avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.