All Projects → ccurtin → postcss-responsive-font

ccurtin / postcss-responsive-font

Licence: MIT license
Simple PostCSS plugin for creating responsive font sizes

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to postcss-responsive-font

Rucksack
A little bag of CSS superpowers, built on PostCSS
Stars: ✭ 1,861 (+6546.43%)
Mutual labels:  postcss, responsive-typography
postcss-import-url
PostCSS plugin inlines remote files.
Stars: ✭ 47 (+67.86%)
Mutual labels:  postcss
elm-tachyons-boilerplate
Simple setup for Elm and Tachyons
Stars: ✭ 17 (-39.29%)
Mutual labels:  postcss
tooltip-generator
💫 A tool to generate CSS code for tooltips. Built with Vue.js and Tailwind CSS
Stars: ✭ 32 (+14.29%)
Mutual labels:  postcss
alfred-postcss-workflow
Alfred App Workflow for https://www.postcss.parts
Stars: ✭ 14 (-50%)
Mutual labels:  postcss
postcss-property-lookup
PostCSS plugin for property lookups, similar to Stylus
Stars: ✭ 67 (+139.29%)
Mutual labels:  postcss
stencil-boilerplate
A Stencil app boilerplate including routing, Redux etc.
Stars: ✭ 51 (+82.14%)
Mutual labels:  postcss
aerostore
🎨 Aerostore - Aerolab Challenge using Next.js and Micro.js from Zeit
Stars: ✭ 20 (-28.57%)
Mutual labels:  postcss
static-webpack-boilerplate
🚀 Minimal & Modern Webpack Boilerplate for building static sites
Stars: ✭ 40 (+42.86%)
Mutual labels:  postcss
faven
A web tool to help you generate favicons
Stars: ✭ 126 (+350%)
Mutual labels:  postcss
sapper-with-postcss-and-tailwind
Basic Sapper app with PostCSS + Tailwind
Stars: ✭ 23 (-17.86%)
Mutual labels:  postcss
vital
Starter template for Vite with React (TypeScript). Supports Tailwind with CSS-Modules. Jest and @react/testing-library configured and ready to go. Also ESLint, Prettier, Husky, Commit-lint and Atomic Design for components.
Stars: ✭ 151 (+439.29%)
Mutual labels:  postcss
postcss
Add PostCSS to your Svelte project
Stars: ✭ 37 (+32.14%)
Mutual labels:  postcss
pwa
An opinionated progressive web app boilerplate
Stars: ✭ 355 (+1167.86%)
Mutual labels:  postcss
gulp-reporter
Error report for: CSSLint/EditorConfig/ESLint/HTMLHint/JSCS/JSHint/PostCSS/Standard/TSLint/XO
Stars: ✭ 17 (-39.29%)
Mutual labels:  postcss
postcss-input-style
PostCSS plugin that adds new pseudo-elements for easily styling the inner elements of inputs
Stars: ✭ 16 (-42.86%)
Mutual labels:  postcss
postcss-center
PostCSS plugin to center elements.
Stars: ✭ 44 (+57.14%)
Mutual labels:  postcss
sveltekit-starter
Sveltekit starter project created with sveltekit, typescript, tailwindcss, postcss, husky, and storybook. The project has the structure set up for the scaleable web application.
Stars: ✭ 482 (+1621.43%)
Mutual labels:  postcss
postcss-if-media
A PostCSS plugin to inline or nest media queries within CSS rules & properties.
Stars: ✭ 35 (+25%)
Mutual labels:  postcss
godlike.css
CSS for layout standardization and usability of web applications
Stars: ✭ 12 (-57.14%)
Mutual labels:  postcss

PostCSS Responsive Font Build Status

Set responsive min/max font-sizes within viewport ranges...

Adds a new declaration that requires 4 values.

font-size-responsive: min-font-size max-font-size min-viewport-width max-viewport-width

Input:

.foo {
    font-size-responsive:12px 32px 480px 1280px;
}

Output:

.foo {
    font-size:12px;
}
@media (min-width:480px) {
    .foo {
        font-size: 32px
    }
}
@media (min-width:480px) and (max-width:1280px) {
    .foo {
        font-size: calc(12px + (32 - 12) * ((100vw - 480px) / (1280 - 480)))
    }
}

Using Multiple Declarations

To use multiple declarations, simply place multiple font-size-responsive declarations in normal cascading order within .foo.

It may be obvious to some, but you do NOT want to use font-size-responsive within a media query. font-size-responsive creates its own media query values based on a user's input so it would not make sense to nest media queries inside of media queries!

Don't forget--using multiple declarations is just like cascading normal CSS-- make sure they are in the appropriate order for the appropriate effect.

To clarify, let's look at a proper example's Input and Output:

Input:

.foo {
    font-size-responsive: 30px 60px 980px 1280px;
    font-size-responsive: 15px 45px 767px 980px;
    font-size-responsive: 12px 20px 480px 600px
}

Output:

.foo {
    font-size: 30px;
    font-size: 15px;
    font-size: 12px
}

@media (min-width: 480px) {
    .foo {
        font-size: 20px
    }
}

@media (min-width: 480px) and (max-width: 600px) {
    .foo {
        font-size: calc(12px + (20 - 12) * ((100vw - 480px) / (600 - 480)))
    }
}

@media (min-width: 767px) {
    .foo {
        font-size: 45px
    }
}

@media (min-width: 767px) and (max-width: 980px) {
    .foo {
        font-size: calc(15px + (45 - 15) * ((100vw - 767px) / (980 - 767)))
    }
}

@media (min-width: 980px) {
    .foo {
        font-size: 60px
    }
}

@media (min-width: 980px) and (max-width: 1280px) {
    .foo {
        font-size: calc(30px + (60 - 30) * ((100vw - 980px) / (1280 - 980)))
    }
}

Not properly cascading your styles will cause bugs! but you knew that already :)

Demo : postcss-responsive-font

Usage

postcss([ require('postcss-responsive-font') ])

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].