GithubHelp home page GithubHelp logo

fossabot / bettertext.css Goto Github PK

View Code? Open in Web Editor NEW

This project forked from paulradzkov/bettertext.css

0.0 1.0 0.0 2.94 MB

Improved default typography for naked HTML or Markdown-generated content.

Home Page: https://paulradzkov.github.io/bettertext.css/

License: MIT License

CSS 65.62% CoffeeScript 34.38%

bettertext.css's Introduction

bettertext.css

npm version bower version FOSSA Status

Improved typography styles for naked HTML (without any classnames) and Markdown-generated content. Demo page

Install

npm install bettertext.css --save-dev

bower install bettertext.css --save

or use compiled version from CDN

  • https://unpkg.com/bettertext.css@latest/bettertext.css  
  • https://unpkg.com/bettertext.css@latest/bettertext.min.css  
  • https://unpkg.com/bettertext.css@latest/bettertext.min.css.map

Usage in HTML

Insert bettertext.css after normalize.css and after your @font-face declaration.

Or include bettertext.less into your project styles.

Default values

Component has global mixin with settings named .bettertext-settings(); and global variable bettertext which contains all the code.

Default settings:

.bettertext-settings() {

    //settings
    @fz: 16px;                         // default font-size in px
    @rythm: 24px;                      // vertical rythm = line-height in pixels
    @fz-small: 12px;                   // smaller font-size (px)
    @linel: 50rem;                     // max-width for text (any css value)
    @font-body: sans-serif;            // body
    @font-headers: sans-serif;         // headers
    @font-code: monospace, monospace;  // code (duplication is intentional)
    @scale1: 1.125;                    // header size multiplier for small screens
    @scale2: 1.250;                    // header size multiplier for large screens

    // margin for body, articles and sections (any css value)
    @structure-margin: ~"calc(24px + 3vw)" 5vw;

    // breakpoint to switch from 'mobile' to 'desktop'
    @bettertext-breakpoint: ~"(min-width: 768px)";

    //calculations
    // ...
}

Usage in LESS

Running with default parameters:

@import (less) "node_modules/bettertext.css/bettertext.less";

Setting up basic parameters:

@import (less) "node_modules/bettertext.css/bettertext.less";

.bettertext-settings() {

    //settings
    @fz: 16px;                          // default font-size
    @font-body: 'Arial', sans-serif;    // body
    @font-headers: 'Georgia', serif;    // headers

    @bettertext-breakpoint: ~"(min-width: 50em)"; // large screens starts from that value

}

Deep customization: you able to redefine any formula in calculation section inside bettertext-settings mixin.

@import (less) "node_modules/bettertext.css/bettertext.less";

.bettertext-settings() {

    //settings
    @fz: 16px;                          // default font-size
    @font-body: 'Arial', sans-serif;    // body
    @font-headers: 'Georgia', serif;    // headers

    @bettertext-breakpoint: ~"(min-width: 50em)"; // large screens starts from that value

    //redefining header margin-top
    @h1-mt: 3em;
    @h2-mt: 2.5em;
    @h3-mt: 2em;
    @h4-mt: 1.5em;
    @h5-mt: unit((2 * @lh * @fz / @h5-fz), em);
    @h6-mt: unit((2 * @lh * @fz / @h6-fz), em);
}

Customizing without LESS

If you are not using LESS on your project you can fork and customize bettertext.css on codepen: adjust settings with your parameters, test with your HTML or Markdown, press "View Compiled" and grab compiled CSS.

License

FOSSA Status

bettertext.css's People

Contributors

paulradzkov avatar ymatuhin avatar fossabot 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.