Responsive Web Design - Grid-View

What is a Grid-View

Many website pages depend on a network see, which implies that the page is separated into columns:

Using a matrix see is useful when planning site pages. It makes it simpler to put components on the page.

A responsive matrix see frequently has 12 sections, and has an absolute width of 100%, and will contract and grow as you resize the program window.

Building a Responsive Grid-View

Lets begin constructing a responsive lattice view.

First guarantee that all HTML components have the box-sizing property set to border-box. This ensures the cushioning and outskirt are incorporated into the all out width and tallness of the elements.

Add the accompanying code in your CSS:

* {
    box-measuring: fringe box;

The following model demonstrates a basic responsive page, with two columns:


.menu {
    width: 25%;
    skim: left;
.fundamental {
    width: 75%;
    skim: left;
Try it yourself »

The model above is fine if the website page just contains two columns.

However, we need to utilize a responsive lattice see with 12 sections, to have more power over the web page.

First we should compute the rate for one segment: 100%/12 sections = 8.33%.

Then we make one class for every one of the 12 segments, class="col-" and a number characterizing what number of segments the segment ought to span:


.col-1 {width: 8.33%;}
.col-2 {width: 16.66%;}
.col-3 {width: 25%;}
.col-4 {width: 33.33%;}
.col-5 {width: 41.66%;}
.col-6 {width: 50%;}
.col-7 {width: 58.33%;}
.col-8 {width: 66.66%;}
.col-9 {width: 75%;}
.col-10 {width: 83.33%;}
.col-11 {width: 91.66%;}
.col-12 {width: 100%;}
Try it yourself »

 All these sections ought to glide the left, and have a cushioning of 15px:


[class*="col-"] {
    drift: left;
    cushioning: 15px;
    outskirt: 1px strong red;

Each line ought to be enclosed by a <div>. The quantity of sections inside a column ought to dependably mean 12:


<div class="row">
  <div class="col-3">...</div>
  <div class="col-9">...</div>

The segments inside a line are for the most part coasting to one side, and are in this way removed from the stream of the page, and different components will be set as though the segments does not exist. To keep this, we will include a style that clears the flow:


.row:after {
    content: "";
    clear: both;
    show: block;

We additionally need to add a few styles and hues to make it look better:


html {
    textual style family: "Lucida Sans", sans-serif;
.header {
    foundation shading: #e8c6c5;
    shading: #ffffff;
    cushioning: 15px;
.menu ul {
    list-style-type: none;
    edge: 0;
    cushioning: 0;
.menu li {
    cushioning: 8px;
    edge base: 7px;
    foundation shading :#e8c6c5;
    shading: #ffffff;
    box-shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24);
.menu li:hover {
    foundation shading: #e8c6c5;
Try it yourself »