Getting started
You can get started using mini.css in one of many ways. It is published on npm and yarn, so you can easily download it, using your preferred package manager:
npm install mini.css
yarn add mini.css
Alternatively, you can use either rawgit or cdnjs to import mini.css into your HTML page's <head>
tag:
<link rel="stylesheet" href="https://cdn.rawgit.com/Chalarangelo/mini.css/v3.0.0-alpha.1/dist/mini-default.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/mini.css/v3.0.0-alpha.1/mini-default.min.css">
After adding mini.css to your project, remember to also add the following line inside your HTML page's <head>
tag to utilize the viewport meta tag:
<meta name="viewport" content="width=device-width, initial-scale=1">
mini.css is crafted with long-term support in mind, so expect it to be compatible with all modern browsers, as well as their future versions. However, most legacy and proxy browsers, such as Internet Explorer, Opera Mini, IE Mobile and UC Browser are not officially supported, meaning certain features may not be displayed properly or behave exactly as expected.
Common textual elements
mini.css utilizes the ruleset of Normalize.css v7.0.0 to reliably deal with inconsistencies between browsers, ensuring that your web apps will look beatiful no matter on what browser or device you're at. On top of these rules, we have applied some tasteful rules, such as using native font stack to figure out the best font for each device, slightly altering the background and foreground colors, as well as setting the size of the text to 16px
and its line height to 1.5
.
All of the most common HTML5 elements, such as paragraphs, links, bold, small and slanted text, have been styled by default using clean, modern typography to make your pages look cool and stand out from the rest of the internet.
Example
This is a paragraph with some sample text. Did you know that the latest version of mini.css is codenamed Gluon? Well, now you do!
Remember that mini.css is totally free, no fine print involved!
Sample code
<p>This is a paragraph. with some <strong>bold text</strong> and some <em>italics text</em>.</p> <a href="#">This is a link.</a> <small>This is some small text.</small> <sub>Subscript</sub> <sup>Superscript</sup> <hr/>
Best practices
/* Do not do this (use Sass instead) */ html { font-size: 14px; }
Don't: Avoid altering the base font size of 16px
directly in your CSS code, as it can cause problems with the display of certain elements.
Customization
- Text color can be changed globally by changing the value of the
--fore-color
variable. - Background color can be changed globally by changing the value of the
--back-color
variable. - Border color can be changed globally by changing the value of the
--border-color
variable. This affects the color of<hr>
elements. - Universal margin for elements can be changed globally by changing the value of the
--universal-margin
variable. As a rule of thumb, consider the universal margin to be the distance you want your paragraphs to have from the sides of the screen. - Universal padding for elements can be changed globally by changing the value of the
--universal-padding
variable. - You can change the color of links by changing the values of the
--a-link-color
and--a-visited-color
variables.
Headings
All of the HTML5 heading elements are styled, using a customizable ratio and simple rules, providing a clean base for your web app's titles. Apart from the headings themselves, customized rules are provided for displaying subheadings or explanatory text below your web app's headings.
Example
Heading 1Subheading
Heading 2Subheading
Heading 3Subheading
Heading 4Subheading
Heading 5Subheading
Heading 6Subheading
Sample code
<h1>Heading 1 <small>Subheading</small></h1> <h2>Heading 2 <small>Subheading</small></h2> <h3>Heading 3 <small>Subheading</small></h3> <h4>Heading 4 <small>Subheading</small></h4> <h5>Heading 5 <small>Subheading</small></h5> <h6>Heading 6 <small>Subheading</small></h6>
Customization
- Text color can be changed globally by changing the value of the
--fore-color
variable. This will affect the color of the headings' main text. - Secondary text color can be changed globally by changing the value of the
--secondary-fore-color
variable. This will affect the color of subheadings. - Universal margin for elements can be changed globally by changing the value of the
--universal-margin
variable. As a rule of thumb, consider the universal margin to be the distance you want your paragraphs to have from the sides of the screen. - You can change the ratio of headings' size by chaning the value of the
--heading-ratio
variable. Bear in mind that the value of this variable must be unitless to work properly.
Lists
List elements, both unordered and ordered, are minimally styled to match with the rest of the framework's aesthetics. Their margins and padding are reset to properly align with the rest of the common HTML5 elements, providing a stable foundation for all of your web app's lists.
Example
- Apple
- Orange
- Strawberry
- Wake up
- Eat breakfast
- Go to work
Sample code
<ul> <li>Apple</li> <li>Orange</li> <li>Strawberry</li> </ul> <ol> <li>Wake up</li> <li>Eat breakfast</li> <li>Go to work</li> </ol>
Customization
- Text color can be changed globally by changing the value of the
--fore-color
variable. - Background color can be changed globally by changing the value of the
--back-color
variable. - Universal margin for elements can be changed globally by changing the value of the
--universal-margin
variable. As a rule of thumb, consider the universal margin to be the distance you want your paragraphs to have from the sides of the screen. - Universal padding for elements can be changed globally by changing the value of the
--universal-padding
variable.
Code & quotations
Code blocks and quotation elements are styled using custom rules that help make them stand out from the rest of the text, while inline code and keyboard input tags are styled in a similar manner, while aiming not to break the flow of regular text.
Example
This is some text with some inline source code
and some keyboard input.
function sum(num1, num2){ return num1 + num2; }
This is some text quoted from elsewhere.
Sample code
<p>This is some text with some inline <code>source code</code> and some keyboard <kbd>input</kbd>.</p> <pre>function sum(num1, num2){ return num1 + num2; }</pre> <blockquote cite="www.quotation.source">This is some text quoted from elsewhere.</blockquote>
Notes
- The
cite
attribute of<blockquote>
elements is not mandatory and can be omitted. The element's sizing will be automatically adjusted according to the presence of thecite
attribute.
Customization
- Text color can be changed globally by changing the value of the
--fore-color
variable. This will affect the text color of<code>
and<pre>
elements and background color of<kbd>
elements. - Background color can be changed globally by changing the value of the
--back-color
variable. This will affect the background color of<blockquote>
elements and text color of<kbd>
. - You can change the background color of
<code>
and<pre>
elements by changing the value of the--secondary-back-color
variable. - You can change the text color of
<blockquote>
elements by changing the value of the--secondary-fore-color
variable. - You can change the border color of
<pre>
and<blockquote>
elements by changing the value of the--secondary-border-color
variable. - You can change the border color of the left border of
<pre>
elements by changing the value of the--pre-color
variable. - You can change the border color of the left border of
<blockquote>
elements by changing the value of the--blockquote-color
variable. - Universal margin for elements can be changed globally by changing the value of the
--universal-margin
variable. As a rule of thumb, consider the universal margin to be the distance you want your paragraphs to have from the sides of the screen. - Universal padding for elements can be changed globally by changing the value of the
--universal-padding
variable. - Universal border radius for elements can be changed globally by changing the value of the
--universal-border-radius
variable.
Grid system
The grid system of mini.css utilizes the Flexbox layout to provide you with a simple, modern, responsive layout system for your web apps. Like most modern CSS frameworks' grid systems, it is composed of three main components - containers, rows and columns:
- The container (
.container
) is the outermost layer of the grid system and serves as a fluid wrapper, which can be used as the basis for your layout. - Inside the container, you can add one or more rows (
.row
), which will in turn house the columns. - Columns (
col-*-*
) are placed inside rows and they can be customized to display differently on different screen sizes, make use of fluid layouts, use offsets or change ordering.
Example
Sample code
<div class="container"> <div class="row"> <div class="col-sm-1"></div> <div class="col-sm-11"></div> </div> <div class="row"> <div class="col-sm-2"></div> <div class="col-sm-10"></div> </div> <div class="row"> <div class="col-sm-3"></div> <div class="col-sm-9"></div> </div> <div class="row"> <div class="col-sm-4"></div> <div class="col-sm-8"></div> </div> <div class="row"> <div class="col-sm-5"></div> <div class="col-sm-7"></div> </div> <div class="row"> <div class="col-sm-6"></div> <div class="col-sm-6"></div> </div> <div class="row"> <div class="col-sm-12"></div> <div class="row"> <div class="col-sm"></div> <div class="col-sm"></div> </div> </div>
You can use the grid system to create a responsive media object in one of many ways. Below is a simple example of a two-column media object with an image and some text:
<div class="row"> <div class="col-sm-2"> <img src="image.png" alt="Image description"/> </div> <div class="col-sm"> <h2>Media object heading</h2> <p>Media object content...</p> </div> </div>
Modifiers
Screen sizes and width
Each column class is defined by specifying a screen size (small - sm
, medium - md
or large - lg
) and a column width (a value between 1
and 12
or you can omit it for a fluid column), separated by dashes (e.g. .col-sm-6
for a 6-wide column on a small screen). Using these you can apply different layouts for different screen sizes, by altering the width of columns, using multiple classes. Note that column widths are applied recursively, meaning that if you do not specify a width for a specific screen size the column will use the width applied for the previous largest screen size.
Example
Small screen layout
Medium/Large screen layout
Sample code
<div class="container"> <div class="row"> <div class="col-sm-12 col-md-3 col-lg-2"></div> <div class="col-sm-12 col-md-5 col-lg-7"></div> <div class="col-sm-12 col-md-4 col-lg-3"></div> </div> <div class="row"> <div class="col-sm col-lg-10"></div> <div class="col-sm-4 col-md"></div> </div> </div>
Predefined layouts
Rows can be modified to apply predefined layouts to the columns inside them, effectively reducing the amount of work required for simple layouts. To create a predefined layout, you can add a class to a row (.cols-*-*
), specifying a screen size and width for the columns inside it (or omitting the width for fluid columns), similarly to the way columns are defined (e.g. .row.cols-sm-6
will cause all elements inside the row to be 6-wide on a small screen). Columns inside a predefined layout do not require any further classes to display and, much like normal column layouts, their widths are applied recursively.
Sample code
<div class="row cols-sm-6"> <div> <p>This paragraph is inside a 6-wide column.</p> </div> <div> <p>This paragraph is inside a 6-wide column.</p> </div> </div>
Column offsets
Columns can be moved to the right, by applying offset classes (.col-*-offset-*
), defining a screen size and an offset (a value between 0
and 11
, e.g. .col-sm-offset-3
will move a column 25% to the right on a small screen). Like all other column modifiers, offsets are applied recursively.
Example
Sample code
<div class="row"> <div class="col-sm-8 col-sm-offset-2 col-md-offset-1 col-lg-offset-0"></div></div> <div class="row"> <div class="col-sm col-sm-offset-3 col-md-offset-4 col-lg-offset-0"></div> </div> <div class="row"> <div class="col-sm-4 col-md-offset-5"></div> </div>
Column reordering
Columns can be reordered on different screen sizes, by applying a reordering class (.col-*-*
), defining a screen size and the order (first, normal or last, e.g. .col-sm-last
will move a column to the end of its row on a small screen). Like all other column modifiers, reordering is applied recursively.
Example
Small screen layout
Medium/Large screen layout
Sample code
<div class="row"> <div class="col-sm col-md-last col-lg-normal"></div> <div class="col-sm col-sm-first col-md-last"></div> <div class="col-sm col-md-first col-lg-normal"></div> </div>
Best practices
<div class="col-sm-3"> <div class="container"></div> </div> <div class="col-sm-3"> <div class="row"></div> </div> <div class="col-sm-3 row"> <div class="col-sm-6"></div> <div class="col-sm-6"></div> </div>
Do: A column can contain a container or a row inside it, or even be a row at the same time. In the latter case, it will act as a column for its parent row and as a row for its children.
<div class="row"> <div class="col-sm-12"></div> <div class="col-sm"></div> <div class="col-sm-4"></div> </div>
Do: You can mix fluid columns with fixed, if you like. Fluid columns will adapt to the size of the container left for them. You can also use columns whose total width exceeds 12
(100%). The remaining content will flow below the rest, allowing you to specify multiple blocks of content inside the same row if you need to.
<div class="row"> <div class="col-sm-12 col-md-6"></div> <div class="col-sm-12 col-md-6"></div> </div>
Do: You can change the layout of your content for different displays, laying out your content vertically on smaller screens or horizontally on larger screens. If your columns exceed a total width of 12
(100%) on some displays, they will wrap accordingly.
<div class="row"> <div class="col-sm col-lg-3 col-md-last"></div> <div class="col-sm-6 col-md-offset-2"></div> </div>
Do: You do not need to specify a column's width or reapply offset and reordering modifiers if they are the same as the previous screen size.
<div class="row cols-sm-12 cols-md-6"> <div></div> <div></div> </div>
Do: You can add multiple predefined layout classes for different screen sizes, allowing you to build responsive predefined layouts.
<div class="row"> <div class="col-sm-8 col-sm-offset-1 col-md-offset-0"></div> <div class="col-sm-last col-md-normal"></div> </div>
Do: To remove a previously applied offset from a column (i.e. one applied from the layout from a smaller screen size) or to make sure no offsets are active on a column, you can set its offset to 0
for a specific screen size. Similarly, to remove previously applied reordering modifiers from a column, you can set its order to normal
.
<div class="col-sm"> <div class="col-sm"></div> </div>
Don't: Avoid placing a column directly inside another column. Always use a row to wrap columns, instead.
<div class="container"> <div class="row"> <div class="col-sm"></div> <p>Do not do this.</p> </div> <p>Do not do this.</p> </div>
Don't: Avoid mixing rows and columns with normal content that is not wrapped on the respective level of the grid layout.
<div class="row"> <div class="col-md"></div> </div> <div class="row cols-md"></div>
Don't: Never omit the class that specifies a column's width for the small screen size. You can omit all other classes and modifiers, except for this. This also applies to predefined layouts.
<div class="row cols-sm-6"> <div class="row cols-sm-4"></div> </div>
Don't: Avoid combining normal column width modifiers with predefined layouts, as the predefined layout will most likely override the width modifier of the column.
Notes
- mini.css uses a mobile-first approach in its grid system, so you do not have to rewrite the same layout for all three screen sizes. Leaving a column's size, offset or order unspecified for a screen size will use the style applied for the previous largest screen size recursively. This also applies to predefined layouts.
- The specific breakpoints for small, medium and large screen sizes are as follows:
- small: less than
768px
wide - medium: more than or equal to
768px
wide and less than1280px
wide - large:
1280px
wide or more
- small: less than
- In many cases, you can omit the container and just use rows and columns. You only need to make sure that all of your rows have the same parent element.
- You can use fluid columns to create columns whose width is not a multiple of 1/12th of the screen's width (e.g. if you have 7 fluid columns in a row, each one of them will be 1/7th of the screen's width).
- Predefined layouts can be combined with most of the features of the grid system, such as offsets and reordering, however they do not combine very well with regular columns.
- You should only apply offset and reordering modifiers to the columns that you need and for the screen sizes that are necessary. Remember to also specify a column width or use a predefined layout before applying these modifiers.
Customization
- Universal padding for elements can be changed globally by changing the value of the
--universal-padding
variable. This only affects the padding of the container.