Grid is a fantastic system to arrange different elements smartly on screen. Since screen sizes and orientations vary in different devices, Grid arranges all the elements perfectly for easy readability:
If we built up a row like this:
Then all the equal-width columns will be like:
Three columns of equal width will be like:
Three columns of unequal width will be like:
- - -
- - -
- - -
Here w3-col is a class to create a column. s4 is a subclass that defines the display size (small) and the column width (4). Collectively it means that three columns (each of width-4) will be displayed on a small screen device:
The syntax for a column is like:
For example:
- - -
Now we need to understand that the size subclasses scale up hence,
The following code creates 2 unequal columns (3 + 9) on all devices:
The following code creates (4 + 8) on phones, (3 + 9) on tabs and (2 + 10) on monitors:
The class w3-row-padding adds a left-right padding of 16px to all columns:
Note that –padding adds the padding. Using only w3-row doesn’t add any padding in between columns.
Output:
The columns can be given width in percentages as well:
India
Sri Lanka
Pakistan
Here India is getting 50% of total width, Sri Lanka is getting a 30% width and the Pakistan is getting 20%.
Output:
If the class w3-col is given a width of set pixels/percentage, the rest width can be created as a separate column using w3-rest class:
India
Sri Lanka
Pakistan
Here India is getting 60% of total width, Sri Lanka is getting a 250px width and the rest is given to Pakistan.
Output:
Linux Commands
Computer Networks
Python Programming
Computer System Architecture
HTML  CSS  W3.CSS  JavaScript  ReactJS
Copyright 2018. All Rights Reserved.