Pure CSS is a free and open-source CSS framework. It is a set of resources for building dynamic websites and online applications. This was created by Yahoo and is used to create websites that load more quickly, have a better user experience, and look better. It effectively takes the place of Bootstrap. The responsive design was considered when creating Pure CSS. We consequently get pre-made, consistent adaptable layouts for all platforms.
By adding the pure-g class to a container, Pure CSS Grids are used to generate layouts and construct responsive layouts. Specific classes cannot add padding or borders to grid units, but we can do this using traditional CSS. There are two ways to complete them.
Pure CSS Grids on Mobile means that we develop grid systems mobile-first. Mobile-first grid system means we just need to use the pure-u-* class for all the units of the grid system. The star given in the class given is replaced by the default screen sizes provided by Pure CSS which are sm, md, lg, xl, and xxl. We specify the width of the units of the grid system on mobile first. Using one class will let the grid units take up that same space for every screen size. For example, if we use the pure-u-1-3 class for all the units, the cells will take up width:33.33%, no matter what screen size it is. If we want to make these grid units responsive and appropriate for every screen size we have to add the responsive grid classes to the units.
Pure CSS Grid Used Classes:
- pure-g: This class is used to create a Pure CSS grid system.
- pure-u-m-n: This class is used to add the units of the grid system. The (m,n) can range from (1-5, 0-5) or (1-24, 0-24). This class is mostly used to generate a Pure CSS Regular Grid or to express fixed grid sizes.
- pure-u-*-m-n: This class is also used to add the units of the grid system. The main feature of using this class is the star given in the class replaced by the default screen sizes provided by Pure CSS which are sm, md, lg, xl, and xxl. The space that the grids will occupy on each of these screens is specified by these screen sizes. The main purpose of this class is to build a responsive Pure CSS grid.
Syntax:
<div class="pure-g">
<div class="pure-u-1-2"> ... </div>
<div class="pure-u-1-2"> ... </div>
</div>
Example 1: The code below demonstrates the creation of Pure CSS Grids on Mobile. This grid system is developed which is suitable for mobile screens first, we have used the pure-u-1-2 class which shows the grid units take width: 50% on all screen sizes.
HTML
<!doctype html>
< html lang = "en" >
< head >
< link rel = "stylesheet" href =
< link rel = "stylesheet" href =
< link rel = "stylesheet" href =
< script src =
</ script >
< style >
.l-box{
background-color: aquamarine;
border: 0.5rem salmon solid;
margin-bottom: 0.5rem;
}
.m-box{
background-color: beige;
border: 0.5rem brown solid;
}
</ style >
</ head >
< body >
< div id = "main" >
< div class = "header" >
< h1 style = "color:green;" >GeeksforGeeks</ h1 >
< h2 >Pure CSS Grids on Mobile</ h2 >
</ div >
< div class = "pure-g" >
< div class = "pure-u-1-2" >
< div class = "l-box" >
1st Column for Pure CSS Grids on Mobile
</ div >
</ div >
< div class = "pure-u-1-2" >
< div class = "l-box" >
2nd Column for Pure CSS Grids on Mobile
</ div >
</ div >
</ div >
< div class = "pure-g" >
< div class = "pure-u-1-2" >
< div class = "m-box" >
1st Column for Pure CSS Grids on Mobile
</ div >
</ div >
< div class = "pure-u-1-2" >
< div class = "m-box" >
2nd Column for Pure CSS Grids on Mobile
</ div >
</ div >
</ div >
</ div >
</ body >
</ html >
|
Output:
Example 2: The code below demonstrates the creation of Pure CSS Grids on Mobile. This grid system is developed which is suitable for mobile screens first, we have used the pure-u-1-2 and pure-u-1-3 classes which shows the grid units take width: 50% and width: 33.33% on all screens sizes respectively.
HTML
<!doctype html>
< html lang = "en" >
< head >
< link rel = "stylesheet" href =
< link rel = "stylesheet" href =
< link rel = "stylesheet" href =
< script src =
</ script >
< style >
.l-box{
background-color: aquamarine;
border: 0.5rem salmon solid;
margin-bottom: 0.5rem;
}
.m-box{
background-color: beige;
border: 0.5rem brown solid;
}
</ style >
</ head >
< body >
< div id = "main" >
< div class = "header" >
< h1 style = "color:green;" >GeeksforGeeks</ h1 >
< h2 >Pure CSS Grids on Mobile</ h2 >
</ div >
< div class = "pure-g" >
< div class = "pure-u-1-2" >
< div class = "l-box" >
1st Column for Pure CSS Grids on Mobile
</ div >
</ div >
< div class = "pure-u-1-2" >
< div class = "l-box" >
2nd Column for Pure CSS Grids on Mobile
</ div >
</ div >
</ div >
< div class = "pure-g" >
< div class = "pure-u-1-3" >
< div class = "m-box" >
1st Column for Pure CSS Grids on Mobile
</ div >
</ div >
< div class = "pure-u-1-3" >
< div class = "m-box" >
2nd Column for Pure CSS Grids on Mobile
</ div >
</ div >
< div class = "pure-u-1-3" >
< div class = "m-box" >
3rd Column for Pure CSS Grids on Mobile
</ div >
</ div >
</ div >
</ div >
</ body >
</ html >
|
Output:
Reference: https://purecss.io/grids/#grids-on-mobile
Similar Reads
Pure CSS Grids
While creating a genuine responsive website layout the grid system is a crucial tool for web developers. A grid is a set of classes that helps us to divide the width of the screen or display into smaller units and make the website look responsive on various devices. Pure.CSS also comes up with such
4 min read
How To Use Tailwind CSS Grid?
Tailwind CSS can provide a highly customizable and low-level framework to build responsive and dynamic web layouts using the utility-first classes. One of the most powerful layout systems provided by Tailwind is CSS Grid, which allows developers to create complex and flexible grid-based layouts with
4 min read
Primer CSS Inline block grids
Primer CSS is a free open-source CSS framework that is built with the GitHub design system to provide support to the broad spectrum of Github websites. It creates the foundation of the basic style elements such as spacing, typography, and color. This systematic method makes sure our patterns are ste
2 min read
Primer CSS Grid Nesting
Primer CSS is a free open-source CSS framework that is built upon systems that create the foundation of the basic style elements such as spacing, typography, and color. This systematic method makes sure our patterns are steady and interoperable with every other. Its approach to CSS is influenced by
2 min read
Primer CSS Responsive Grids
Primer CSS is a free open-source CSS framework that is built upon systems that create the foundation of the basic style elements such as spacing, typography, and color. This systematic method makes sure our patterns are steady and interoperable with every other. Its approach to CSS is influenced by
3 min read
Materialize CSS Grids
There are 12 standard columns fluid responsive grid systems that helps you to layout your page in an ordered and easy way. It uses the row and column style classes to define rows and columns respectively. Rows are used to specify a padding-less container to be used for responsive columns and col are
3 min read
Primer CSS Grid
Primer CSS is a free open-source CSS framework that is built with the GitHub design system to provide support to the broad spectrum of Github websites. It creates the foundation of the basic style elements such as spacing, typography, and color. This systematic method makes sure that our patterns ar
4 min read
CSS | Grid Inspector
The Grid Inspector is a powerful tool that enables to verify the grid system by using browser. In the Mozilla Firefox, there is an inbuilt Grid Inspector but in Google Chrome you have to use the extension. Grid Inspector is pretty much helpful grid system is little complex or spanning many tracks. I
1 min read
Pure CSS Introduction
Pure CSS is a framework of CSS. It is a free and open-source tool collection for creating responsive websites and web applications. Pure CSS is developed by Yahoo and is used for creating faster, beautiful, and responsive websites. It can be used as an alternative to Bootstrap. Why we use Pure CSS?
2 min read
CSS Grid Layout Module
CSS Grid Layout is used to design responsive web layouts with rows and columns. It allows you to place items exactly where you want, making it easier to create flexible and modern web pages. Unlike older methods like floats, CSS Grid gives more control over alignment and adapts well to different scr
6 min read