Bootstrap/C2/Order-and-Offset-Classes-in-Bootstrap/English
Title of the script: Order and Offset Classes in Bootstrap
Author: Neha Solanki
Domain Reviewer: Ankita Maske
Novice Reviewer: Abhijit Bonik
Keywords: Bootstrap, CSS, HTML, Web Page, Web Design, Web Technology, Video Tutorial, Spoken Tutorial, Order and Offset Classes in Bootstrap, Order class, Offset class
Visual Cue | Narration |
Slide: Title | Welcome to the Spoken Tutorial on “Order and Offset classes in Bootstrap”. |
Slide 2:
Learning Objectives |
In this tutorial, we will learn about:
while designing a layout. |
Slide 3:
System Requirements |
This tutorial is recorded using:
|
Slide 4: Prerequisite |
|
Slide: Layout
Image1.png Highlight 2nd and 3rd rows |
In this tutorial, we will design a layout as shown here.
We will see how to implement order and offset classes to the columns of 2nd & 3rd rows. |
Slide: Order Classes | Let’s start with order classes.
|
Slide: Order Classes with Breakpoints
table1.png |
Order classes are also set with breakpoints.
Following are the .order classes for different breakpoints. |
Only narration | Let’s understand .order classes with an example. |
Point to Mypage.html & Mystyle.css in My-bootstrap folder | Locate the files Mypage.html and Mystyle.css in the My-bootstrap folder.
We will use Mypage.html and Mystyle.css files which we saved earlier for this demonstration. |
Slide 5: Code Files |
|
Point to Mypage.html in My-bootstrap folder
Open the file in text editor |
Open the file Mypage.html in the text editor. |
[gedit - Mypage.html]
Update: <div class="row"> <div class="col-sm-3 order-sm-last"> <ul> <a href="#"><li> Fruits & Vegetables </li></a> <a href="#"><li> Foodgrain </li></a> <a href="#"><li> Beverages </li></a> <a href="#"><li> Personal care </li></a> <a href="#"><li> Snacks & Branded Foods </li></a> </ul> </div> <div class="col-sm-9"> <h3> Welcome to Online Grocery Shopping!! </h3> <p> Buy your essentials at the lowest price. Choose from fresh produce to packaged goods and get them delivered straight to your doorstep. Shop for Rs.1000 and more to get FREE delivery. <p> </div> </div> <div class="row"> <div class="col-sm-3 order-3"> <h5> ABOUT BHARAT </h5> <p> About us <br> FAQ </p> </div> <div class="col-sm-3 order-2"> <h5> PAYMENT AND SHIPPING </h5> <p> Payment Methods <br> Shipping Policy </p> </div> <div class="col-sm-3 order-1"> <h5> CONTACT US </h5> <p> contact@bharat-online.com <br> 9000000001 </p> </div> </div> |
First we will add the order class in this code.
For the 2nd row 1st column, add order-sm-last class as shown.
This will set the visual order of the first column to the last.
Next we’ll set the order class for the 3rd row which contains 3 columns as shown. i.e 1st column with order-3 class 2nd column with order-2 class 3rd column with order-1 class
|
Press Ctrl + S | Save the file. |
Point to Mypage.html in the My-bootstrap folder
Open Mypage.html in Firefox |
Open the file Mypage.html in a web browser. |
[Firefox]
Textbox [Press Ctrl+Shift+C]</div> Right click >> Inspect Element Textbox [Press Ctrl+Shift+M]</div> Click on Responsive Design Mode Using mouse, by dragging change the size |
In the 3rd row, we see that the visual order of the columns has changed accordingly.
That is, the 1st column became the 3rd and 3rd column became 1st.
In the 2nd row, the visual order of the 1st column which consists of links, is moved to last.
Let’s see how this page behaves in responsive mode after using order class.
By dragging the right border, we’ll decrease the width of the screen to below 576px. Observe that now the column that consists of links, is at the first in this row. |
So we can conclude that its order is set to last for screen size Small and above.
You can also try .order classes with other breakpoints. | |
Next we’ll learn about offset classes. | |
Slide: Offset Classes |
|
Only narration | Let’s understand .offset classes with an example. |
Switch to Mypage.html | Switch to the Mypage.html file in the text editor. |
[gedit - Mypage.html]
Update: <div class="row"> <div class="col-sm-3 order-3 offset-1"> <h5> ABOUT BHARAT </h5> <p> About us <br> FAQ </p> </div> <div class="col-sm-3 order-2 offset-1"> <h5> PAYMENT AND SHIPPING </h5> <p> Payment Methods <br> Shipping Policy </p> </div> <div class="col-sm-3 order-1 offset-1"> <h5> CONTACT US </h5> <p> contact@bharat-online.com <br> 9000000001 </p> </div> </div> |
Add the offset-1 class to all the columns in the 3rd row, as shown.
|
Press Ctrl + S | Save the file. |
Switch to firefox | Switch to the browser and refresh the page. |
[Firefox]
Using mouse, by dragging change the size |
We see that the margin of 1 grid column is added to the left of each of the three columns.
So we can say that each column has shifted to the right by 1 grid column.
At every screen size, offset remains the same. |
Slide: Offset Class with Breakpoints
table2.png |
Offset classes can also be set with breakpoints.
Following are the .offset classes for different breakpoints. |
Only narration | Now let’s understand this with an example. |
Switch to Mypage.html | Switch to the Mypage.html file. |
[gedit - Mypage.html]
Update: <div class="row"> <div class="col-sm-3 order-3 offset-sm-1"> <h5> ABOUT BHARAT </h5> <p> About us <br> FAQ </p> </div> <div class="col-sm-3 order-2 offset-sm-1"> <h5> PAYMENT AND SHIPPING </h5> <p> Payment Methods <br> Shipping Policy </p> </div> <div class="col-sm-3 order-1 offset-sm-1"> <h5> CONTACT US </h5> <p> contact@bharat-online.com <br> 9000000001 </p> </div> </div> |
We will look for Small breakpoint.
In the 3rd row, update the offset class for all the columns to offset-sm-1 as shown. |
Press Ctrl + S | Save the file. |
Switch to firefox | Switch to the browser and refresh the page. |
[Firefox]
Using mouse, by dragging change the size |
Observe that the margin of 1 grid column is set before all the three columns.
By dragging the right border, we’ll decrease the width of the screen to below 576px. Now the margin of 1 grid column is not set.
You can also try .offset class with other breakpoints. |
This is the final layout which we have designed using order and offset classes. | |
Only narration | With this we have come to the end of this tutorial.
Let us now summarize. |
Slide 6: Summary | In this tutorial, we have learnt about:
while designing a layout |
Slide 8: Assignment | Do the below assignment-
|
Slide:
About Spoken Tutorial project |
The video at the following link summarises the Spoken Tutorial project.
Please download and watch it. |
Slide: Spoken Tutorial Workshops | The Spoken Tutorial Project team conducts workshops and gives certificates.
For more details, please write to us. |
Slide: Forum | Please post your timed queries on this forum. |
Slide: Acknowledgement | Spoken Tutorial project is funded by Ministry of Education (MoE), Govt. of India. |
Slide: Thanks | This is Neha Solanki from Spoken Tutorial, IIT Bombay signing off.
Thanks for watching. |