Pure CSS Regular Grid vs Responsive Grid
Last Updated :
01 Aug, 2022
Pure CSS is a free and open-source CSS framework. It is a collection of tools for creating online programs and responsive web pages. This was developed by Yahoo and is used to make websites that load faster, look better, and are easier to use. Bootstrap is effectively replaced by it. When developing Pure CSS, the responsive design was taken into account. As a result, we receive ready-made, uniform responsive layouts for all platforms.
Pure CSS Grids are used to generate layouts and create responsive layouts by applying the pure-g class to a container. Grid units cannot have padding or borders added by particular classes, but we may achieve this with conventional CSS. These can be done in one of two ways, which are listed below.
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 mainly used to describe the fixed grid sizes or this is used to create a pure CSS regular grid.
- pure-u-*-m-n: This class is also used to create a 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. These screen sizes are used to specify how much space the grids will take in the respective screen size. This class is mainly used to create a responsive Pure CSS grid.
Pure CSS Regular Grid vs. Responsive Grid: The fundamental difference between the two is the usage of class which is used to create this which is specified above. In the regular grid, we specify the width taken by the grid and it is fixed irrespective of the screen size.
In the responsive grid, we specify the width taken by the grid in specific screen sizes, it dynamically changes the sizes of the grid when the screen size is changed.
The below example specifies that each unit of the grid will take up 50% width, irrespective of the screen size. We can understand that the regular grid is unresponsive.
Syntax:
<div class="pure-g">
<div class="pure-u-1-2"> ... </div>
...
</div>
The below code snippet demonstrates the creation of a responsive grid using pure-u-1 and pure-u-md-1-4 classes. This means that the units will have a width: 100% on only small screens and a width: 25% on medium-sized screens and above.
Syntax:
<div class="pure-g">
<div class="pure-u-1 pure-u-md-1-4"> ... </div>
...
</div>
Example 1: The code below demonstrates the creation of the pure CSS regular grid and we can see how it behaves in different screen sizes. We have used the pure-u-1-2 class for the units which specify width:50% on all screen sizes.
HTML
<!doctype html>
<html lang="en">
<head>
<link rel="stylesheet" href=
"https://unpkg.com/[email protected]/build/pure-min.css">
<link rel="stylesheet" href=
"https://unpkg.com/[email protected]/build/grids-min.css">
<link rel="stylesheet" href=
"https://unpkg.com/[email protected]/build/grids-responsive-min.css">
<script src=
"https://purecss.io/js/ui.js">
</script>
<style>
.l-box {
background-color: aquamarine;
border: 0.5rem salmon solid;
}
body {
margin-left:10px;
margin-right:10px;
}
</style>
</head>
<body>
<div id="main">
<div class="header">
<h1 style="color:green;">GeeksforGeeks</h1>
<h2>Pure CSS Regular Grid vs. Responsive Grid</h2>
</div>
<div class="pure-g">
<div class="pure-u-1-2">
<div class="l-box">
1st Column Regular Grid
</div>
</div>
<div class="pure-u-1-2">
<div class="l-box">
2nd Column Regular Grid
</div>
</div>
</div>
</div>
</body>
</html>
Output:
Example 2: The code below demonstrates how to create a Pure CSS Responsive grid and we can see how it behaves in different screen sizes. Here we have used pure-u-1-2 pure-u-md-1-3 pure-u-lg-1-4 classes for every unit, which specifies that each div will have width:50%, width:33.33% and width:25% in small, medium and large screen-sizes respectively.
HTML
<!doctype html>
<html lang="en">
<head>
<link rel="stylesheet" href=
"https://unpkg.com/[email protected]/build/pure-min.css">
<link rel="stylesheet" href=
"https://unpkg.com/[email protected]/build/grids-min.css">
<link rel="stylesheet" href=
"https://unpkg.com/[email protected]/build/grids-responsive-min.css">
<script src=
"https://purecss.io/js/ui.js">
</script>
<style>
.l-box {
background-color: aquamarine;
border: 0.5rem salmon solid;
}
body {
margin-left:10px;
}
</style>
</head>
<body>
<div id="main">
<div class="header">
<h1 style="color:green;">GeeksforGeeks</h1>
<h2>Pure CSS Regular Grid vs. Responsive Grid</h2>
</div>
<div class="pure-g">
<div class="pure-u-1-2 pure-u-md-1-3 pure-u-lg-1-4">
<div class="l-box">
1st Column Responsive Grid
</div>
</div>
<div class="pure-u-1-2 pure-u-md-1-3 pure-u-lg-1-4">
<div class="l-box">
2nd Column Responsive Grid
</div>
</div>
</div>
</div>
</body>
</html>
Output:
Reference: https://purecss.io/grids/
Similar Reads
Pure CSS Responsive Grids Pure CSS is a free and open-source framework of CSS. CSS Grid Layout is a method designed for the two-dimensional layout of items with rows and columns. It consists of both unresponsive and responsive modules. Responsive design's function is to display the contents of the website automatically acros
4 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
React Suite Grid Responsive React Suite is a front-end library designed for the middle platform and back-end products. React Suite Grid component provides a grid layout that provides 24 grids, It helps in responsiveness. For responsiveness we pass the following props to the Col Component: xxl: It takes a number as a value. The
4 min read
How to Create a Responsive CSS Grid Layout ? Here are different ways to create a responsive grid layout with CSS.1. Using auto-fill PropertyThis method can be used CSS Grid for a responsive layout. The grid-template-columns property adjusts columns based on space, keeping a minimum width of 200 pixels. Gaps between items are set with grid-gap.
3 min read
Pure CSS Grids Units Sizes Pure CSS is a CSS framework. It is a free and open-source tool collection for creating responsive web applications. It was developed by Yahoo and is used for creating faster, more beautiful, and more responsive layouts. Pure Grids are easy to work with and very powerful in creating grid layouts in w
3 min read
What to understand Pure CSS Responsive Design ? In this article, we will learn about Pure.CSS responsive design. It is a collection of responsive CSS modules that can be included in any web application to create faster, beautiful, and responsive websites. In simple words, it is a framework of CSS that is used to build a beautiful and responsive w
3 min read
Pure CSS Grids Complete Reference Pure CSS is a popular framework & an open-source tool, developed by Yahoo, for creating responsive websites & web applications by making use of the responsive CSS modules, that help to develop a better user experience with high efficiency. It can be used as an alternative to Bootstrap. The G
1 min read
How to Create a Responsive Image Grid using CSS? A responsive image grid is a layout technique used to display images in a grid-like structure that adjusts dynamically based on the screen size to ensure that the grid looks good and functions well across various devices and screen resolutions. Below are the approaches to creat a responsive image gr
3 min read
Create Responsive Column Cards with CSS Responsive column cards with CSS refer to card-like elements arranged in columns that adapt to different screen sizes. Using flexible layouts, media queries, and CSS properties, these cards automatically adjust their size and arrangement, ensuring an optimal viewing experience across devices.Here we
3 min read
React Suite Grid <Col> Props React Suite is a popular front-end library with a set of React components that are designed for the middle platform and back-end products. The grid component allows the user to provide 24 grids. It helps in achieving response design. There are different props for react suite grid rows and columns f
5 min read