Bootstrap Interview Questions

This article is a list of top Bootstrap interview questions and answers.

Question 1: What is Bootstrap?


Answer

Bootstrap is the most popular and powerful HTML, CSS, and JavaScript front-end framework for faster and easier use, responsive layout, and mobile-first web development. It includes design templates for UI components like Forms, Buttons, Tables, Navigation, Dropdowns, Alerts, Tabs, Accordion, Carousel and many others with optional JavaScript plugins.

Features of Bootstrap 
  • Easy to use
    Bootstrap is very easy to use. Anyone with the basic knowledge of HTML and CSS can start development with Bootstrap.

  • Open Source
    Bootstrap is completely free to download and use.

  • Browser compatibility
    Bootstrap is compatible with all modern browsers like Google Chrome, Mozilla Firefox, Internet Explorer, Safari, and Opera.

  • Responsive features
    By using Bootstrap we can easily create responsive designs for web pages. Bootstrap's responsive CSS makes our web pages appear more appropriately on different devices as it adjusts to phones, tablets, and desktops.

For more details visit the following link,

Question 2: Why choose Bootstrap for building websites?


Answer

Bootstrap is used for building websites for the following reasons,
  • Mobile First Approach: Since Bootstrap 3, the framework consists of Mobile first styles throughout the entire library instead of in separate files.
  • Browser Support: It is supported by all popular browsers.
  • Easy to Get Started: With just the knowledge of HTML and CSS anyone can get started with Bootstrap.
  • Responsive Design: Bootstrap's responsive CSS adjusts to Desktops, Tablets and Mobiles.
  • Provides a clean and uniform solution for building an interface for developers.
  • It contains beautiful and functional built-in components that are easy to customize. It also provides web based customization.

For more details visit the following link,

Question 3: Explain the use of Bootstrap CSS class="navnav-list".


Answer

You need to add the nav-list class in addition to the nav class that will make it look like a list. And adding class nav-header to any element of the nav class will make it look like a heading to the section of links. The HTML File looks as in the following, 
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">  
  2. <html>  
  3.   
  4. <head>  
  5.     <title></title>  
  6.     <script src="Scripts/jquery-1.4.1.min.js" type="text/javascript"></script>  
  7.     <link href="Bootstrap/css/bootstrap.css" rel="stylesheet" type="text/css" />  
  8.     <script src="Bootstrap/js/bootstrap.min.js" type="text/javascript"></script>  
  9. </head>  
  10.   
  11. <body>  
  12.     <ul class="navnav-list">  
  13.         <li class="nav-header">Category</li>  
  14.         <li><a href="#">.NET</a></li>  
  15.         <li><a href="#">ASP.NET</a></li>  
  16.         <li><a href="#">Silverlight</a></li>  
  17.         <li><a href="#">WCF</a></li>  
  18.         <li class="nav-header">Database</li>  
  19.         <li><a href="#">SQL Server</a></li>  
  20.         <li><a href="#">Oracle</a></li>  
  21.         <li><a href="#">MySQL</a></li>  
  22.     </ul>  
  23. </body>  
  24.   
  25. </html>  
Now see how the list is rendering.

see how the list is rendering

For more details visit the following link - 

Question 4: Explain Bootstrap Grid System.


Answer

Bootstrap grid system provides the fastest and easiest way to create layouts of web pages. It introduces the responsive mobile first fluid grid system that appropriately scales up to 12 columns as the device or view port size increases. It includes predefined grid classes for making grid layouts for various types of devices, like phones, tablets, desktop, and so on, as well as powerful mixings for generating more semantic layouts.

The Grid Sizes

It has four tiers of classes: xs, sm, md and lg. You can use any combination of these classes to create more dynamic and flexible layouts. The following is the breakdown of the various sizes of these classes.
 
Classes Devices Size
.col-xs-* Extra Small Phones Less than 768px
.col-sm-* Small Devices Tablets 768px and Up
.col-md-* Medium Devices Desktops 992px and Up
.col-lg-* Large Devices Large Desktops 1200px and Up

Structure of Bootstrap Grid Layout,

Structure of Bootstrap Grid Layout

Working of Bootstrap Grid System

Grid systems are used for creating page layouts through a series of rows and columns . Here's how the Bootstrap grid system works,

  • Rows must be placed within a .container and .container-fluid class for proper alignment and padding.
  • Use rows to create horizontal groups of columns.
  • Content should be placed within columns and only columns may be immediate children of rows.
  • Predefined grid classes like .row and .col-xs-4 are available for quickly making grid layouts. LESS mixings can also be used for more semantic layouts.
  • Grid columns are created by specifying the number of twelve available columns you wish to span. For example, three equal columns would use three .col-xs-4.

For more details visit the following link,

Question 5: How can you get Bootstrap?


Answer

There are two ways to get Bootstrap on our own web site. 
  • Download Bootstrap.
  • Include Bootstrap from a CDN.

Download Bootstrap

We can download the latest version of Bootstrap. When we click on this link we will see screen like this.

download the latest version of Bootstrap

Now if we click on the Download Bootstrap button, another page will open like this:

click on Download Bootstrap button

There are two versions available for download, compiled Bootstrap and Bootstrap source files.

  • Download Bootstrap

    By clicking on this option, we can download the precompiled and minified versions of Bootstrap CSS, JavaScript, and fonts.

    After downloading, we will unzip the folder and we will find the following subfolders inside that.

    Download Bootstrap

  • Download Source

    By clicking on this option, we can get the latest Bootstrap LESS and JavaScript source code.

    For better understanding we'll focus on the compiled Bootstrap files. As the files are compiled and minified we don't have to bother every time including separate files for individual functionality. It will also increase the performance of our website.

Bootstrap CDN

If we don't want to download, we can include it from a CDN (Content Delivery Network). MaxCDN provides CDN support for Bootstrap's CSS and JavaScript and also includes jQuery. We can use Bootstrap CDN links,

  1. <!-- Latest compiled and minified CSS -->   
  2. <link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">   
  3. <!-- jQuery library -->   
  4. <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>   
  5. <!-- Latest compiled JavaScript -->   
  6. <script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>   
For more details visit the following link, 

Question 6: What do you understand about Responsive websites?


Answer

The first understanding of Responsive websites that comes to a beginner's mind is that responsive means a website that responds to a user. But actually, responsiveness here means that a website is designed in such a way that it can be used on any platform whether it is a large desktop, laptop, tablet or mobile.

So a responsive website actually is one that responds to the changing width and height of a device or screen.

Benefits of a responsive website 
  • We all know that in today's world, all of the business work can be done using a small device like a tablet or a mobile. So it makes it easier for the user to access the website using a device, thus, increasing the user base and traffic on a website.
  • When the user base increases, it also adds to the increase in the business of the website and the product sale will also increase.
  • Makes it easy for an organization to analyze the user base and its productivity.
  • Increase in the visibility in search engines. This is the major part of the success of an organization.
  • Save time and cost on mobile development.

For more details visit the following link -

Question 7: How can you create a web page using Bootstrap?


Answer

Example:

Using Downloaded Bootstrap

Now we will create an HTML file that displays a "Hello C# Corner" message in our web browser.

Step 1

Creating a Basic HTML file.

First we will open any code editor and create a new html file, and we will write the following code and then save the file name as "hello.html" on the particuler location. We will include HTML5 doctype at the beginning of the page, with the lang attribute and the correct character set. 
  1. <!DOCTYPE html>  
  2. <html lang="en">  
  3.   
  4. <head>  
  5.     <meta charset="utf-8">  
  6.     <title>Bootstrap Part1</title>  
  7. </head>  
  8.   
  9. <body>  
  10.     <h1>Hello C# Corner</h1>  
  11. </body>  
  12.   
  13. </html>  
Step 2

Bootstrap 3 is mobile-first.

Using Bootstrap 3 we will design our HTML page to be responsive to mobile devices. To ensure proper rendering and enable touch zooming, we will add the following <meta> tag inside the <head> element.
  1. <meta name="viewport" content="width=device-width,initial-scale=1">   
The width=device-width is used to set the width of the page to follow the screen-width of the device. The initial-scale=1 is used to set the initial zoom level when the page is first loaded by the browser.

Now the code will look like this.
  1. <!DOCTYPE html>  
  2. <html lang="en">  
  3.   
  4. <head>  
  5.     <meta charset="utf-8">  
  6.     <title>Bootstrap Part1</title>  
  7.     <meta name="viewport" content="width=device-width,initial-scale=1">  
  8. </head>  
  9.   
  10. <body>  
  11.     <h1>Hello C# Corner</h1>  
  12. </body>  
  13.   
  14. </html>  
Step 3

Making an HTML File a Bootstrap Template.

For making this file a Bootstrap Template, after Downloading Bootstrap by the above procedure we will include Bootstrap CSS and JS files. We should include JS files at the bottom of the HTML page before closing <body> tag. by the following code.
  1. <!DOCTYPE html>  
  2. <html lang="en">  
  3.   
  4. <head>  
  5.     <meta charset="utf-8">  
  6.     <title>Bootstrap Part1</title>  
  7.     <meta name="viewport" content="width=device-width,initial-scale=1">  
  8.     <link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">  
  9. </head>  
  10.   
  11. <body>  
  12.     <h1>Hello C# Corner</h1>  
  13.     <script src="js/jquery-2.1.4.min.js"></script>  
  14.     <script src="js/bootstrap.min.js"></script>  
  15. </body>  
  16.   
  17. </html>  

Now we will open the file in a browser by double clicking on it and see the output.

Output

lets see the output

For more details visit the following link -

Question 8: How can you create Fixed Layout with Bootstrap?


Answer

With Bootstrap you can create layouts of web pages based on a fixed number of pixels. To create the fixed yet responsive layout you should start the container with the .container class. Then create the row with the .row class to wrap the horizontal groups of columns. Rows must be placed within a container for proper alignment and padding. Further columns can be created within rows using the predefined grid classes like .col-xs-*, .col-sm-*, .col-md-* and .col-lg-* where * represents a grid number.

The following code creates a fixed width responsive layout that is 970px wide on a medium device like desktop and laptop with a screen width ≥992px and 1170px wide on large devices like large desktops with a screen width ≥1200px. However the layout width will be automatically calculated for devices that have a screen width <768px like tablets and cell phones.

HTML Code
  1. <!DOCTYPE html >  
  2. <html>  
  3.   
  4. <head>  
  5.     <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />  
  6.     <title>Fixed Layout with Bootstrap</title>  
  7.     <!-- compiled and minified CSS -->  
  8.     <link rel="stylesheet" href="css/bootstrap.min.css">  
  9.     <!-- Optional theme -->  
  10.     <link rel="stylesheet" href="css/bootstrap-theme.min.css">  
  11. </head>  
  12.   
  13. <body>  
  14.     <div class="container">  
  15.         <div class="jumbotron">  
  16.             <h1>Fixed Layout with Bootstrap </h1>  
  17.             <p>With Bootstrap you can create layouts of web pages based on fixed number of pixels. To create the fixed yet responsive layout you should starts container with the .container class. After that create row with the .row class to wrap the horizontal groups of columns. Rows must be placed within a container for proper alignment and padding. Further columns can be create within rows using the predefined grid classes like .col-xs-*, .col-sm-*, .col-md-* and .col-lg-* where * represent grid number.</p>  
  18.         </div>  
  19.         <div class="row">  
  20.             <div class="col-sm-4">  
  21.                 <h2>HTML</h2>  
  22.                 <p>HTML is a markup language that is used for creating web pages. The HTML tutorial section will help you understand the basics of HTML, so that you can create your own web pages or website.</p>  
  23.             </div>  
  24.             <div class="col-sm-4">  
  25.                 <h2>CSS</h2>  
  26.                 <p>CSS is used for describing the presentation of web pages. The CSS tutorial section will help you learn the essentials of CSS, so that you can fine control the style and layout of your HTML document.</p>  
  27.             </div>  
  28.             <div class="col-sm-4">  
  29.                 <h2>Bootstrap</h2>  
  30.                 <p>Bootstrap is a powerful front-end framework for faster and easier web development. The Bootstrap tutorial section will help you learn the techniques of Bootstrap so that you can quickly create your own website.</p>  
  31.             </div>  
  32.         </div>  
  33.         <hr>  
  34.     </div>  
  35.   
  36.     <!-- compiled and minified JavaScript -->  
  37.     <script type="text/javascript" src="js/bootstrap.min.js"></script>  
  38. </body>  
  39.   
  40. </html>  
Result

On a tablet, desktop and larger device,

desktop view

Mobile Device

Mobile Device

For more details visit the following link - 

Question 9: How can we create a dropdown menu in Bootstrap?


Answer

To make the menu more attractive with a DropDown list using Bootstrap open up the bootstrap.css file and check out the following Bootstrap CSS class. 
  1. Caret Class
  2. DropDown-Menu Class

1. Using bootstrap CSS class="Caret"

Now first we use the caret class with li tag. The Caret class shows a caret sign. Now open the bootstrap.css file and find the .navbar-inverse class. It looks like this,

  1. .caret   
  2. {  
  3.     displayinline - block;  
  4.     width0;  
  5.     height0;  
  6.     margin - left: 2 px;  
  7.     vertical - align: middle;  
  8.     border - top: 4 px solid;  
  9.     border - right: 4 px solid transparent;  
  10.     border - left: 4 px solid transparent;  
  11. }  
The HTML file looks as in the following,
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">  
  2. <html>  
  3.   
  4. <head>  
  5.     <title></title>  
  6.     <script src="Scripts/jquery-1.4.1.min.js" type="text/javascript"></script>  
  7.     <link href="Bootstrap/css/bootstrap.css" rel="stylesheet" type="text/css" />  
  8.     <script src="Bootstrap/js/bootstrap.min.js" type="text/javascript"></script>  
  9. </head>  
  10.   
  11. <body>  
  12.     <div class="navbar-inverse">  
  13.         <div class="Container">  
  14.             <ul class="navnavbar-nav">  
  15.                 <li><a href="#">Home</a></li>  
  16.                 <li><a href="#about">Technologies</a></li>  
  17.                 <li><a href="#contact">Article</a></li>  
  18.                 <li><a href="#contact">blog</a></li>  
  19.                 <li><a href="#contact">News <b class ="caret"></b></a></li>  
  20.             </ul>  
  21.         </div>  
  22.     </div>  
  23. </body>  
  24.   
  25. </html>  
The HTML will render without Bootstrap as in the following:

main menu

2. Using bootstrap CSS class="DropDown-Menu"

You now need to add the DropDown-Menu class. Now open the bootstrap.css file and find the DropDown-Menu class. It looks like this,
  1. .dropdown - menu  
  2. {  
  3.     positionabsolute;  
  4.     top: 100 % ;  
  5.     left: 0;  
  6.     z - index: 1000;  
  7.     displaynone;  
  8.     floatleft;  
  9.     min - width160 px;  
  10.     padding5 px 0;  
  11.     margin2 px 0 0;  
  12.     font - size14 px;  
  13.     list - style: none;  
  14.     background - color#ffffff;  
  15.     border1 px solid# cccccc;  
  16.     border1 px solid rgba(0000.15);  
  17.     border - radius: 4 px; -  
  18.     webkit - box - shadow: 0 6 px 12 px rgba(0000.175);  
  19.     box - shadow: 0 6 px 12 px rgba(0000.175);  
  20.     background - clip: padding - box;  
  21. }  
The HTML file looks as in the following,
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">  
  2. <html>  
  3.   
  4. <head>  
  5.     <title></title>  
  6.     <script src="Scripts/jquery-1.4.1.min.js" type="text/javascript"></script>  
  7.     <link href="Bootstrap/css/bootstrap.css" rel="stylesheet" type="text/css" />  
  8.     <script src="Bootstrap/js/bootstrap.min.js" type="text/javascript"></script>  
  9.     <script src="Bootstrap/js/bootstrap.min.js" type="text/javascript"></script>  
  10.     <script src="Bootstrap/js/bootstrap.js" type="text/javascript"></script>  
  11. </head>  
  12.   
  13. <body>  
  14.     <div class="navbarnavbar-inverse">  
  15.         <div class="Container">  
  16.             <ul class="navnavbar-nav">  
  17.                 <li><a href="#">Home</a></li>  
  18.                 <li><a href="#about">Technologies</a></li>  
  19.                 <li><a href="#contact">Article</a></li>  
  20.                 <li><a href="#contact">blog</a></li>  
  21.                 <li class="dropdown"><a href="#" class="dropdown-toggle">News <b class="caret"></b></a>  
  22.                     <ul class="dropdown-menu">  
  23.                         <li><a href="#">Home</a></li>  
  24.                         <li><a href="#">Technologies</a></li>  
  25.                         <li><a href="#">Article</a></li>  
  26.                         <li><a href="#">blog</a></li>  
  27.                     </ul>  
  28.                 </li>  
  29.             </ul>  
  30.         </div>  
  31.     </div>  
  32.     <script src="Bootstrap/js/jquery.js" type="text/javascript"></script>  
  33.     <script src="Bootstrap/js/dropdown.js" type="text/javascript"></script>  
  34.     <script type="text/javascript">  
  35.         $(document).ready(function() {  
  36.             $('.dropdown-toggle').dropdown();  
  37.         });  
  38.     </script>  
  39. </body>  
  40.   
  41. </html>  
The HTML will be rendered with Bootstrap as in the following,

sub menu

For more details visit the following link - 

Question 10: How can you create a menu using navbar-inverse in Bootstrap?


Answer

First create a list using ul and li tags. The HTML file looks as in the following,
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">  
  2. <html>  
  3.   
  4. <head>  
  5.     <title></title>  
  6.     <script src="Scripts/jquery-1.4.1.min.js" type="text/javascript"></script>  
  7.     <link href="Bootstrap/css/bootstrap.css" rel="stylesheet" type="text/css" />  
  8.     <script src="Bootstrap/js/bootstrap.min.js" type="text/javascript"></script>  
  9. </head>  
  10.   
  11. <body>  
  12.     <ul>  
  13.         <li><a href="#">Home</a></li>  
  14.         <li><a href="#about">Technologies</a></li>  
  15.         <li><a href="#contact">Article</a></li>  
  16.         <li><a href="#contact">blog</a></li>  
  17.         <li><a href="#contact">News</a></li>  
  18.     </ul>  
  19. </body>  
  20.   
  21. </html>  
HTML will render without Bootstrap as in the following,

table

Using bootstrap CSS class="navbar-inverse"

You now need to add the navbar-inverse class.

Now open the bootstrap.css file and find the .navbar-inverse class. It looks like this,
  1. .navbar - inverse   
  2. {  
  3.     background - color#222222;  
  4. border-color: # 080808;  
  5. }  
Now we want to change the background-color with "background-color: #0029ff".
  1. .navbar-inverse {  
  2. background-color#0029ff;  
  3. border-color#080808;  
  4. }  
The HTML file looks  as in the following,
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">  
  2. <html>  
  3.   
  4. <head>  
  5.     <title></title>  
  6.     <script src="Scripts/jquery-1.4.1.min.js" type="text/javascript"></script>  
  7.     <link href="Bootstrap/css/bootstrap.css" rel="stylesheet" type="text/css" />  
  8.     <script src="Bootstrap/js/bootstrap.min.js" type="text/javascript"></script>  
  9. </head>  
  10.   
  11. <body>  
  12.     <div class="navbar-inverse">  
  13.         <ul>  
  14.             <li><a href="#">Home</a></li>  
  15.             <li><a href="#about">Technologies</a></li>  
  16.             <li><a href="#contact">Article</a></li>  
  17.             <li><a href="#contact">blog</a></li>  
  18.             <li><a href="#contact">News</a></li>  
  19.         </ul>  
  20.     </div>  
  21. </body>  
  22.   
  23. </html>  
The HTML will be rendered with Bootstrap as in the following:

check result

For more details visit the following link -  

Question 11: What are the advantages of Bootstrap?


Answer

There are many advantages of using Bootstrap,
  • Bootstrap Css library takes care of our UI to make  interactive mobile + desktop enabled websites, developers can even create a fully furnished jaw dropping website easily.
  • The speed of development can be increased with the help of Bootstrap.
  • With the increase in mobile first, website designers need to work a lot in order to make the UI adapt to all kinds of devices, whereas with the help of bootstrap this overhead has been reduced to quite an extent.
  • Responsive Grid: As you go in depth with Bootstrap and read about Grid you will see that 12 columns are grids and are responsive and you can make them self-adjusting according to the device.
  • There is a huge list of Components --  Dropdown menu, badges etc. A few have been discussed in this article.
  • Easy to read documentation: I personally believe if you want to learn Bootstrap from scratch http://getbootstrap.com/ documentation is easy and great to start with. I personally appreciate their efforts we can go back to the site whenever we something is  needed in our View.
  • Themes: Bootstrap provides free colorful themes that can be used in our Web Application.
  • Support

For more details visit the following link,

Question 12: What are Containers in Bootstrap?


Answer

In Bootstrap we can contain elements to wrap site contents.

There are two Bootstrap Container classes,
  1. The .container class used to provide a responsive fixed width container.
  2. The .container-fluid class used to provide a full width container.

We have to note that we cannot put a container inside another container since it is not nestable.

Example 1

Using .container class (responsive fixed width container)


In this example we will create a simple Bootstrap page. Using ".container" class we will create a fixed width container that is responsive for different devices. In this we will write some text. We will have some space on the left and right side of the page by writing the following code.

  1. <!DOCTYPE html>  
  2.   
  3. <html lang="en">  
  4.   
  5. <head>  
  6.     <meta charset="utf-8">  
  7.     <title>Bootstrap Part2</title>  
  8.     <meta name="viewport" content="width=device-width,initial-scale=1">  
  9.     <link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">  
  10. </head>  
  11.   
  12. <body>  
  13.     <div class="container">  
  14.         <h1>This Is Bootstrap Page With Responsive Fixed Width Container</h1>  
  15.         <p>This Container Show Output Of Using (.container) Class</p>  
  16.     </div>  
  17.     <script src="js/jquery-2.1.4.min.js"></script>  
  18.     <script src="js/bootstrap.min.js"></script>  
  19. </body>  
  20.   
  21. </html>  
Output

container

responsive fixed width container

Example 2

Using .container-fluid class (full width container)

In this example we will create a simple Bootstrap page like Example 1. Using ".container-fluid"class we will create a full width container. In this we will write some text. Now we will create a page by writing the following code.
  1. <!DOCTYPE html>  
  2.   
  3. <html lang="en">  
  4.   
  5. <head>  
  6.     <meta charset="utf-8">  
  7.     <title>Bootstrap Part2</title>  
  8.     <meta name="viewport" content="width=device-width,initial-scale=1">  
  9.     <link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">  
  10. </head>  
  11.   
  12. <body>  
  13.     <div class="container-fluid">  
  14.         <h1>This Is Bootstrap Page With Full Width Container</h1>  
  15.         <p>This Container Show Output Of Using (.container-fluid) Class</p>  
  16.     </div>  
  17.     <script src="js/jquery-2.1.4.min.js"></script>  
  18.     <script src="js/bootstrap.min.js"></script>  
  19. </body>  
  20.   
  21. </html>  
Output

check output

For more details visit the following link - 

Question 13: Explain the basic structure of the Bootstrap grid.


Answer

Now for creating rows and columns using 12 column responsive grid systems. 
  • First we need to create a container that acts as a wrapper for our rows and columns by using the .container class.
  • Then we have to create rows inside the container by using (<div class="row">) ,
  • Then we need to add the desired number of columns inside any row by using classes .col-xs-*, .col-sm-*, .col-md-* and .col-lg-* the number of columns should always add up to 12 for each row. In these columns we write our contents.

The following is a Basic Structure,

Basic Structure

  1. <div class="container">  
  2.     <div class="row">  
  3.         <div class="col-*-*">col1</div>  
  4.         <div class="col-*-*">col2</div>  
  5.         <div class="col-*-*">col3</div>  
  6.     </div>  
  7.     <div class="row">  
  8.         ...  
  9.     </div>  
  10. </div>  
Now we will create some examples for Grid Layouts by which we can easily make responsive website layouts.

Example 1

Two Column Layouts


In this example we will create two column layouts for different devices. In mobile the column will automatically arrange horizontally according to screen size. We know that grid system works on 12 columns, so for creating two column layouts we keep the sum of the grid column numbers equal to 12 in each row so columns will be in one line. In this example we will add three rows and inside each row we will add two columns. Let's create the example.

Step 1

First we will create a Bootstrap Template, HTML page named "TwoColLayout.html" by using the following code.
  1. <!DOCTYPE html>  
  2.   
  3. <html lang="en">  
  4.   
  5. <head>  
  6.     <meta charset="utf-8">  
  7.     <title>Bootstrap Part3</title>  
  8.     <meta name="viewport" content="width=device-width,initial-scale=1">  
  9.     <link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">  
  10. </head>  
  11.   
  12. <body>  
  13.     <div class="container">  
  14.         <h1>Two Column Layouts</h1>  
  15.     </div>  
  16.     <script src="js/jquery-2.1.4.min.js"></script>  
  17.     <script src="js/bootstrap.min.js"></script>  
  18. </body>  
  19.   
  20. </html>  
Step 2

Now we will add rows and columns for creating Two Column Layouts by the following code; in this we will give style "background-color" for each column so output shows clearly.
  1. <!DOCTYPE html>  
  2.   
  3. <html lang="en">  
  4.   
  5. <head>  
  6.     <meta charset="utf-8">  
  7.     <title>Bootstrap Part3</title>  
  8.     <meta name="viewport" content="width=device-width,initial-scale=1">  
  9.     <link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">  
  10. </head>  
  11.   
  12. <body>  
  13.     <div class="container">  
  14.         <h1>Two Column Layouts</h1>  
  15.         <!--First row with column number(4,8)-->  
  16.         <div class="row">  
  17.             <div class="col-sm-4" style="background-color:#8dc1aa">column1: col-sm-4</div>  
  18.             <div class="col-sm-8" style="background-color:#808080">column2: col-sm-8</div>  
  19.         </div>  
  20.         <!--Second row with column number(6,6)-->  
  21.         <div class="row">  
  22.             <div class="col-sm-6" style="background-color:#cfa6e2">column3: col-sm-6</div>  
  23.             <div class="col-sm-6" style="background-color:#faa76c">column4: col-sm-6</div>  
  24.         </div>  
  25.         <!--Third row with column number(3,9)-->  
  26.         <div class="row">  
  27.             <div class="col-sm-3" style="background-color:#c8fcfc">column5: col-sm-3</div>  
  28.             <div class="col-sm-9" style="background-color: #79ad96">column6: col-sm-9</div>  
  29.         </div>  
  30.     </div>  
  31.     <script src="js/jquery-2.1.4.min.js"></script>  
  32.     <script src="js/bootstrap.min.js"></script>  
  33. </body>  
  34.   
  35. </html>  
Output

See the output for different devices according to screen size.

Two Column Layouts

For more details visit the following link - 

Question 14: Explain Bootstrap buttons and its styles.


Answer

Buttons play various roles in websites and applications and are used to submit, reset, show and hide on click of button, link button etc.

By using Bootstrap we can easily create and customize the buttons.

Bootstrap Button Styles

In Bootstrap different classes are used for styling the buttons and styles can be applied to any element like <a>, <button> and <input>.

Bootstrap provides seven styles of buttons,

Button

To apply the button styles, Bootstrap provides the following classes,

 

  • .btn-default - Default gray color Standard button
  • .btn-primary - To indicate primary action button
  • .btn-info - Used for informational alert messages
  • .btn-success - Indicates a successful or positive action
  • .btn-danger - Indicates a dangerous or negative action.
  • .btn-warning - Indicates caution should be taken with this action
  • .btn-link - Button looks like a link while maintaining button behavior

Example

Bootstrap Button Styles,

In this example we will create buttons and by using above classes we will apply styles on buttons through the following code.

  1. <!DOCTYPE html>  
  2. <html lang="en">  
  3.   
  4. <head>  
  5.     <meta charset="utf-8">  
  6.     <title>Bootstrap Part4</title>  
  7.     <meta name="viewport" content="width=device-width,initial-scale=1">  
  8.     <link rel="stylesheet" type="text/css" href="css/bootstrap.min.css"> </head>  
  9.   
  10. <body>  
  11.     <div class="container">  
  12.         <h1>Button Styles</h1>  
  13.         <!--Button Style1:Default--><button type="button" class="btn btn-default">Default Button</button>  
  14.         <!--Button Style2:Primary--><button type="button" class="btn btn-primary">Primary Button</button>  
  15.         <!--Button Style3:Info--><button type="button" class="btn btn-info">Info Button</button>  
  16.         <!--Button Style4:Success--><button type="button" class="btn btn-success">Success Button</button>  
  17.         <!--Button Style5:Danger--><button type="button" class="btn btn-danger">Danger Button</button>  
  18.         <!--Button Style6:Warning--><button type="button" class="btn btn-warning">Warning Button</button>  
  19.         <!--Button Style7:Link--><button type="button" class="btn btn-link">Link Button</button> </div>  
  20.     <script src="js/jquery-2.1.4.min.js"></script>  
  21.     <script src="js/bootstrap.min.js"></script>  
  22. </body>  
  23.   
  24. </html>  
Output

Bootstrap Button Styles

For more details visit the following link - 

Question 15: Explain the Bootstrap basic table?


Answer

The following table elements are used with Bootstrap,

 

  • <table> - It is used for wrapping element for displaying data in a tabular format
  • <thead> - It is used for container element for table header rows (<tr>) to label table columns.
  • <tbody> - It is used for container element for table rows (<tr>) in the body of the table.
  • <tr> - It is used for container element for a set of table cells (<td> or <th>) that appears on a single row.
  • <th> - Special table cell for column (or row) labels. It must be used within a <thread>
  • <td> - It is used for default table cell.
  • <caption> - It is used for description or summary of what the table holds.

Bootstrap Basic Table

We can create a basic Bootstrap table with basic styling that has a small cell padding and only horizontal dividers by adding Bootstrap class ".table" to the <table> element.

Example

Bootstrap Basic Table using .table class.

In this example we will create a simple table with Bootstrap class and using html table elements we will create an employee table with Fields Sr. No., Employee Name, Email, City by writing the following code.

  1. <!DOCTYPE html>  
  2. <html lang="en">  
  3.   
  4. <head>  
  5.     <meta charset="utf-8">  
  6.     <title>Bootstrap Part5</title>  
  7.     <meta name="viewport" content="width=device-width,initial-scale=1">  
  8.     <link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">  
  9. </head>  
  10.   
  11. <body>  
  12.     <div class="container">  
  13.         <h1>Bootstrap Basic Table</h1>  
  14.         <!--Bootstrap Basic Table using .table class-->  
  15.         <table class="table">  
  16.             <thead>  
  17.                 <tr>  
  18.                     <th>Sr.No.</th>  
  19.                     <th>Emolpyee Name</th>  
  20.                     <th>Email</th>  
  21.                     <th>City</th>  
  22.                 </tr>  
  23.             </thead>  
  24.             <tbody>  
  25.                 <tr>  
  26.                     <td>1</td>  
  27.                     <td>Shaili Dashora</td>  
  28.                     <td>abc@mail.com </td>  
  29.                     <td>Chittorgarh</td>  
  30.                 </tr>  
  31.                 <tr>  
  32.                     <td>2</td>  
  33.                     <td>Sourabh Somani</td>  
  34.                     <td>xyz@mail.com </td>  
  35.                     <td>Banglore</td>  
  36.                 </tr>  
  37.                 <tr>  
  38.                     <td>3</td>  
  39.                     <td>Shobhna Singvi</td>  
  40.                     <td>pqr@mail.com</td>  
  41.                     <td>Mumbai</td>  
  42.                 </tr>  
  43.             </tbody>  
  44.         </table>  
  45.     </div>  
  46.     <script src="js/jquery-2.1.4.min.js"></script>  
  47.     <script src="js/bootstrap.min.js"></script>  
  48. </body>  
  49.   
  50. </html>  
Output

Basic Table Layout,

Basic Table Layout

For more details visit the following link - 

Question 16: How can you give a style to images in Bootstrap?


Answer

By using the Bootstrap classes we can easily style images like making images round, cornered, or circular, or we can give a thumbnail effect on images. We have the following classes for image shapes.
  • Rounded Corners - The .img-rounded class used for adding rounded corners to an image.
  • Circle - The .img-circle class used for shaping the image to a circle.
  • Thumbnail - The .img-thumbnail class used for shaping the image to a thumbnail.

Example - Bootstrap Image Shapes

In this example we will give different shapes of images using the above Bootstrap classes, we will put an image inside images folder where our html page exists. After that, we will give shapes on image: Rounded, Circle, or Thumbnail by using the following code.

Output

Bootstrap Image Shapes,

Bootstrap Image Shapes

For more details visit on to following link,

Question 18: What is panel in Bootstrap?


Answer

A panel in bootstrap is a bordered box with some padding around its content. To create a basic panel, we use .panel class to the <div> element, and content inside the panel has a .panel-body class.

Example 1 - Creating Panel

In this example we will create a basic panel by using .panel class to the <div> element and we will write content in the panel by using .panel-body class to the <div> element. In this example we will use .panel-default class for styling of the panel by writing the following code.

 

  1. <!DOCTYPE html>  
  2.   
  3. <html lang="en">  
  4.   
  5. <head>  
  6.     <meta charset="utf-8">  
  7.     <title>Bootstrap Part7</title>  
  8.     <meta name="viewport" content="width=device-width,initial-scale=1">  
  9.     <link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">  
  10. </head>  
  11.   
  12. <body>  
  13.     <div class="container">  
  14.         <h2>Bootstrap Panel</h2>  
  15.         <div class="panel panel-default">  
  16.             <div class="panel-body">Demo Panel</div>  
  17.         </div>  
  18.     </div>  
  19.     <script src="js/jquery-2.1.4.min.js"></script>  
  20.     <script src="js/bootstrap.min.js"></script>  
  21. </body>  
  22.   
  23. </html>  
Output

panel in Bootstrap

For more details visit the following link - 

Question 19: What is Jumbotron in Bootstrap?


Answer

A Jumbotron provides some different look for a heading or we can say it is used to show some special content or information on the webpages, it is displayed as a gray box with rounded corners. It also increase the font sizes of the text inside it. To create a Jumbotron we use <div> element with class.jumbotron.

Creating Jumbotron Inside Container

We place the Jumbotron component by using .jumbotron class inside the <div> with class .container by which it is not extended to the edge of the screen.

Example - Jumbotron Inside Container

In this example we will create a <div> with .container class, inside it we will add one <div> with class.jumbotron and inside jumbotron we can put any HTML, Bootstrap elements for Heading, Descriptions, etc. We will create jumbotron by writing the following code.

 

  1. <!DOCTYPE html>  
  2.   
  3. <html lang="en">  
  4.   
  5. <head>  
  6.     <meta charset="utf-8">  
  7.     <title>Bootstrap Part8</title>  
  8.     <meta name="viewport" content="width=device-width,initial-scale=1">  
  9.     <link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">  
  10. </head>  
  11.   
  12. <body>  
  13.     <div class="container">  
  14.         <!--Creating Jumbotron inside container-->  
  15.         <div class="jumbotron">  
  16.             <h1>Bootstrap Jumbotron</h1>  
  17.             <p>It is Bootstrap Jumbotron inside Container</p>  
  18.             <p><a href="#" class="btn btn-info" role="button">See More Information</a></p>  
  19.         </div>  
  20.     </div>  
  21.     <script src="js/jquery-2.1.4.min.js"></script>  
  22.     <script src="js/bootstrap.min.js"></script>  
  23. </body>  
  24.   
  25. </html>  
Output

Jumbotron inside Container.

Jumbotron

For more details visit the following link - 

Question 20: Explain the Bootstrap progress bar.


Answer

Now we will create different types of progress bars and see how they are useful for webpages.

Basic Progress Bar

We can create a default progress bar, by adding .progress class to a <div> element.

Example - Creating Default Progress Bar

In this example to create a basic progress bar we will add a <div> with class .progress inside the container, now inside this <div>.

We will add one more <div> with class .progress-bar, we will also add width in style attribute that indicates the progress of task or action.

We will add .sr-only class for Progress Bar,

 

  • .sr-only - It is used to hide an element to all devices except screen readers

We will add following properties for Progress Bar,

  • aria-valuenow - It is used to define the current value for a range for Progress Bar
  • aria-valuemin - It is used to define the minimum allowed value for a range
  • aria-valuemax - It is used to define the maximum allowed value for a range

Let's create an example for Default Progress Bar by writin the following code.

  1. <!DOCTYPE html>  
  2.   
  3. <html lang="en">  
  4.   
  5. <head>  
  6.     <meta charset="utf-8">  
  7.     <title>Bootstrap Part9</title>  
  8.     <meta name="viewport" content="width=device-width,initial-scale=1">  
  9.     <link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">  
  10. </head>  
  11.   
  12. <body>  
  13.     <div class="container">  
  14.         <h3>Basic Bootstrap Progress Bar (30% Complete)</h3>  
  15.         <!-- A <div> element with class .progress -->  
  16.         <div class="progress">  
  17.             <!-- A <div> element with class .progress-bar -->  
  18.             <div class="progress-bar" role="progressbar" aria-valuenow="30" aria-valuemin="0" aria-valuemax="100" style="width:30%">  
  19.                 <span class="sr-only">30% Complete Process</span>  
  20.             </div>  
  21.         </div>  
  22.     </div>  
  23.     <script src="js/jquery-2.1.4.min.js"></script>  
  24.     <script src="js/bootstrap.min.js"></script>  
  25. </body>  
  26.   
  27. </html>  
Output

Creating Default Progress Bar

For more details visit the following link - 

Question 21: What contextual classes are used with progress bars in Bootstrap?


Answer

The contextual classes used with progress bars are:

 

  • .progress-bar-info
  • .progress-bar-success
  • .progress-bar-danger
  • .progress-bar-warning

Creating Progress Bars with Contextual classes

In this example to create Colored Progress Bars we will add <div> with class .progress inside the container, now inside this <div> we will add one more <div> with class .progress-bar and we will add Contextual classes here like .progress-bar-info,.progress-bar-success,.progress-bar-danger,.progress-bar-warning. We will also add width in style attribute that indicates the progress of the task or action. We will also add aria attributes for progress bar, by writing the following code.

  1. <!DOCTYPE html>  
  2.   
  3. <html lang="en">  
  4.   
  5. <head>  
  6.     <meta charset="utf-8">  
  7.     <title>Bootstrap Part9</title>  
  8.     <meta name="viewport" content="width=device-width,initial-scale=1">  
  9.     <link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">  
  10. </head>  
  11.   
  12. <body>  
  13.     <div class="container">  
  14.         <h3>Colored Progress Bars with Contextual classes</h3>  
  15.         <div class="progress">  
  16.             <!-- A <div> element with class .progress-bar and .progress-bar-info -->  
  17.             <div class="progress-bar progress-bar-info" role="progressbar" aria-valuenow="30" aria-valuemin="0" aria-valuemax="100" style="width:30%">  
  18.                 30% Complete Process (Info)  
  19.             </div>  
  20.         </div>  
  21.         <div class="progress">  
  22.             <!-- A <div> element with class .progress-bar and .progress-bar-success -->  
  23.             <div class="progress-bar progress-bar-success" role="progressbar" aria-valuenow="50" aria-valuemin="0" aria-valuemax="100" style="width:50%">  
  24.                 50% Complete Process (Success)  
  25.             </div>  
  26.         </div>  
  27.         <div class="progress">  
  28.             <!-- A <div> element with class .progress-bar and .progress-bar-danger -->  
  29.             <div class="progress-bar progress-bar-danger" role="progressbar" aria-valuenow="70" aria-valuemin="0" aria-valuemax="100" style="width:70%">  
  30.                 70% Complete Process (Danger)  
  31.             </div>  
  32.         </div>  
  33.         <div class="progress">  
  34.             <!-- A <div> element with class .progress-bar and .progress-bar-warning -->  
  35.             <div class="progress-bar progress-bar-warning" role="progressbar" aria-valuenow="90" aria-valuemin="0" aria-valuemax="100" style="width:90%">  
  36.                 90% Complete Process (Warning)  
  37.             </div>  
  38.         </div>  
  39.     </div>  
  40.     <script src="js/jquery-2.1.4.min.js"></script>  
  41.     <script src="js/bootstrap.min.js"></script>  
  42. </body>  
  43.   
  44. </html>  
Output

Contextual classes

For more details visit the following link - 

Question 22: Explain Bootstrap Basic Buttons.


Answer

The basic list group is like an unordered list with list items. For creating a Basic List Group use class .list-group to <ul> element, and into this <li> elements.

Example - Basic List Groups

In this example first we will create a <div> with class .container, then for Basic List Group, we will add <ul> element with class .list-group and inside this we will add <li> elements with class .list-group-item, and in this we will add elements of list.

Let’s create a Basic List Group by writing the following code and see the output.

 

  1. <!DOCTYPE html>  
  2.   
  3. <html lang="en">  
  4.   
  5. <head>  
  6.     <meta charset="utf-8">  
  7.     <title>Bootstrap Part10</title>  
  8.     <meta name="viewport" content="width=device-width,initial-scale=1">  
  9.     <link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">  
  10. </head>  
  11.   
  12. <body>  
  13.     <div class="container">  
  14.         <h3>Basic Bootstrap List Group</h3>  
  15.         <p>FOOD CATEGORY</p>  
  16.         <ul class="list-group">  
  17.             <li class="list-group-item">SWEETS</li>  
  18.             <li class="list-group-item">SNACKS</li>  
  19.             <li class="list-group-item">MISE</li>  
  20.             <li class="list-group-item">REGIONAL</li>  
  21.             <li class="list-group-item">BAKING</li>  
  22.         </ul>  
  23.     </div>  
  24.     <script src="js/jquery-2.1.4.min.js"></script>  
  25.     <script src="js/bootstrap.min.js"></script>  
  26. </body>  
  27.   
  28. </html>   

Output

Basic List Groups

For more details visit the following link -

Question 23: How can you create Responsive Tables with Bootstrap?


Answer

In Bootstrap 3 we can create a responsive table by using .table-responsive class. The table will scroll horizontally on small devices (screen width under 768px). When viewing on larger than 768px wide, we will not see any difference in tables.

Example - Creating Responsive Table

In this example to make the table responsive we will place the table inside a <div> element and then we will apply the class .table-responsive on it by using the following code.

 

  1. <!DOCTYPE html>  
  2. <html lang="en">  
  3.   
  4. <head>  
  5.     <meta charset="utf-8">  
  6.     <title>Bootstrap Part5</title>  
  7.     <meta name="viewport" content="width=device-width,initial-scale=1">  
  8.     <link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">  
  9. </head>  
  10.   
  11. <body>  
  12.     <div class="container">  
  13.         <h1>Bootstrap Responsive Table</h1>  
  14.         <!-- Div using .table-responsive class-->  
  15.         <div class="table-responsive">  
  16.             <!--Bootstrap Table using .table class-->  
  17.             <table class="table">  
  18.                 <thead>  
  19.                     <tr>  
  20.                         <th>Sr.No.</th>  
  21.                         <th>Emolpyee Name</th>  
  22.                         <th>Salary</th>  
  23.                         <th>City</th>  
  24.                     </tr>  
  25.                 </thead>  
  26.                 <tbody>  
  27.                     <tr>  
  28.                         <td>1</td>  
  29.                         <td>Shaili Dashora</td>  
  30.                         <td>50,000</td>  
  31.                         <td>Banglore</td>  
  32.                     </tr>  
  33.                     <tr>  
  34.                         <td>2</td>  
  35.                         <td>Sourabh Somani</td>  
  36.                         <td>1,20,000</td>  
  37.                         <td>Dehli</td>  
  38.                     </tr>  
  39.                     <tr>  
  40.                         <td>3</td>  
  41.                         <td>Milan</td>  
  42.                         <td>40,000</td>  
  43.                         <td>Udaipur</td>  
  44.                     </tr>  
  45.                     <tr>  
  46.                         <td>4</td>  
  47.                         <td>KumKum</td>  
  48.                         <td>30,000</td>  
  49.                         <td>Banglore</td>  
  50.                     </tr>  
  51.                     <tr>  
  52.                         <td>5</td>  
  53.                         <td>Bhumika</td>  
  54.                         <td>20,000</td>  
  55.                         <td>Udaipur</td>  
  56.                     </tr>  
  57.                 </tbody>  
  58.             </table>  
  59.         </div>  
  60.     </div>  
  61.     <script src="js/jquery-2.1.4.min.js"></script>  
  62.     <script src="js/bootstrap.min.js"></script>  
  63. </body>  
  64.   
  65. </html>  
Output

Responsive Table Layout,

Responsive Table Layout

Responsive Table

For more details visit the following link - 

Question 24: Explain Navigation Bar in Bootstrap.


Answer

The Bootstrap navbar component is used to create a responsive navigation header for our website or application. A navigation bar can collapse or extend, according to the screen size of different devices.

Default Navigation Bar (navbar)

For creating default navbar we need to use <nav class="navbarnavbar-default"> and we can add responsive Default Navigation Bar to the top of the page in any web application.

Example 1 - Creating Default Navbar


Step 1

In this example we will create a default navbar. For this first we will create a basic Bootstrap HTML page by using the following code.

 

  1. <!DOCTYPE html>  
  2.   
  3. <html lang="en">  
  4.   
  5. <head>  
  6.     <meta charset="utf-8">  
  7.     <title>Bootstrap Part11</title>  
  8.     <meta name="viewport" content="width=device-width,initial-scale=1">  
  9.     <link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">  
  10. </head>  
  11.   
  12. <body>  
  13.   
  14.     <script src="js/jquery-2.1.4.min.js"></script>  
  15.     <script src="js/bootstrap.min.js"></script>  
  16. </body>  
  17.   
  18. </html>  
Step 2

Now to create default navbar, 
  • In the <body> of the HTML page we will add <nav> tag with classes .navbar, .navbar-default.
  • Inside this we will add <div> with class .container-fluid.
  • In this we will add one <div> with header class .navbar-header, now we will add <a> element with class navbar-brand. By using this text becomes slightly larger in size.
  • Now for adding links to the navbar we will add unordered list (ul) with the classes .nav, .navbar-nav and provide menu links using <li> element.

Let's create default navbar by using the following code,

  1. <!DOCTYPE html>  
  2.   
  3. <html lang="en">  
  4.   
  5. <head>  
  6.     <meta charset="utf-8">  
  7.     <title>Bootstrap Part11</title>  
  8.     <meta name="viewport" content="width=device-width,initial-scale=1">  
  9.     <link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">  
  10. </head>  
  11.   
  12. <body>  
  13.     <!--Default Navbar Start Here-->  
  14.     <!--<nav> tag start with classes .navbar and .navbar-default-->  
  15.     <nav class="navbar navbar-default">  
  16.         <div class="container-fluid">  
  17.             <!--Navbar Header Start Here-->  
  18.             <div class="navbar-header">  
  19.                 <a class="navbar-brand" href="#">C-sharp Corner</a>  
  20.             </div>  
  21.             <!--Navbar Header End Here-->  
  22.             <!--Menu Start Here-->  
  23.             <ul class="nav navbar-nav">  
  24.                 <li class="active"><a href="#">Home</a></li>  
  25.                 <li><a href="#">About Us</a></li>  
  26.                 <li><a href="#">Technology</a></li>  
  27.                 <li><a href="#">Contact Us</a></li>  
  28.             </ul>  
  29.             <!--Menu End Here-->  
  30.         </div>  
  31.     </nav>  
  32.     <!--<nav> tag end-->  
  33.     <!--Default Navbar End Here-->  
  34.     <script src="js/jquery-2.1.4.min.js"></script>  
  35.     <script src="js/bootstrap.min.js"></script>  
  36. </body>  
  37.   
  38. </html>  
Output

Default Navigation Bar (navbar).

Default Navigation Bar

For more details visit the following link - 

Question 25: What are the Responsive Utilities Classes in Bootstrap?


Answer
 
You can use the following responsive classes to enable the element's visibility depending on the device screen sizes.
 
Class Description
.visible-xs-* The elements visible only on extra small devices having screen width less than 768px. Hidden on others.
.visible-sm-* The elements visible only on small devices having screen width greater than or equal to 768px. Hidden on others.
.visible-md-* The elements visible only on medium devices having screen width greater than or equal to 992px. Hidden on others.
.visible-lg-* The elements visible only on larger devices having screen width greater than or equal to 1200px. Hidden on others.

Note

You can also mix these classes to make the elements visible on multiple devices.

HTML Code

  1. <!DOCTYPE html >  
  2. <html>  
  3.   
  4. <head>  
  5.     <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />  
  6.     <title>Responsive</title>  
  7.     <!-- compiled and minified CSS -->  
  8.     <link rel="stylesheet" href="css/bootstrap.min.css">  
  9.     <!-- Optional theme -->  
  10.     <link rel="stylesheet" href="css/bootstrap-theme.min.css">  
  11. </head>  
  12.   
  13. <body>  
  14.     <p class="visible-xs-block">This paragraph is visible only on extra small devices.</p>  
  15.     <p class="visible-sm-block">This paragraph is visible only on small devices.</p>  
  16.     <p class="visible-md-block">This paragraph is visible only on medium devices.</p>  
  17.     <p class="visible-lg-block">This paragraph is visible only on large devices.</p>  
  18.     <!-- compiled and minified JavaScript -->  
  19.     <script type="text/javascript" src="js/bootstrap.min.js"></script>  
  20. </body>  
  21.   
  22. </html>  
Similarly you can use these hidden utility classes to hide the elements depending on the devices.
 
Class Description
.hidden-xs-* Hide the elements only on extra small devices having screen width less than 768px. Visible on others.
.hidden-sm-* Hide the elements only on small devices having screen width greater than or equal to 768px. Visible on others.
.hidden-md-* Hide the elements only on medium devices having screen width greater than or equal to 992px. Visible on others.
.hidden-lg-* Hide the elements only on larger devices having screen width greater than or equal to 1200px. Visible on others.

Code

  1. <p class="hidden-xs">This paragraph is hidden only on extra small devices.</p>   
  2. <p class="hidden-sm">This paragraph is hidden only on small devices.</p>   
  3. <p class="hidden-md">This paragraph is hidden only on medium devices.</p>   
  4. <p class="hidden-lg">This paragraph is hidden only on large devices.</p>   
For more details visit the following link - 

Question 26: Explain Layout in Bootstrap.


Answer

Twitter Bootstrap Layout has two different layouts. The first is fixed layout and the second is fluid layout. Bootstrap has added the responsive features for phone, tablets and websites that are a perfect view for large-screen desktops to small-screen desktops.

Fixed/ Grid Layout

If we are looking for a webpage or app layout on a fixed number of size (pixels), then we choose fixed layout.

 

  1. <body>  
  2.     <div class="container">  
  3.         <p> Hello World !</p>  
  4.         <p> Hello World !</p>  
  5.         <p> Hello World !</p>  
  6.         <p> Hello World !</p>  
  7.         <p> Hello World !</p>  
  8.         <p> Hello World !</p>  
  9.         <p> Hello World !</p>  
  10.         <p> Hello World !</p>  
  11.     </div>  
  12. </body>  
Grid Layout

Fluid Layout

If we want to create a layout that is not fixed, not on the basis of percentage to keep it flexible, then we choose fluid layout.
  1. <div class="container-fluid">  
  2.     <div class="row-fluid">  
  3.         <div class="span2">  
  4.             <p>Hello </p>  
  5.             <p>Hello </p>  
  6.             <p>Hello </p>  
  7.             <p>Hello </p>  
  8.             <p>Hello </p>  
  9.         </div>  
  10.         <div class="span10">  
  11.             <p>World !</p>  
  12.             <p>World !</p>  
  13.             <p>World !</p>  
  14.             <p>World !</p>  
  15.             <p>World !</p>  
  16.   
  17.         </div>  
  18.     </div>  
  19. </div>  
Fluid Layout

For more details visit the following link - 

Question 27: How can you create forms using Twitter Bootstrap?


Answer

To make the forms more attractive using Bootstrap, open up the bootstrap.css file and check out the following Bootstrap CSS class.
  1. Vertical Form (default form layout)
  2. Horizontal Form
  3. Inline Form

1. Using default form layout

Now first we use the form tag with label and TextBox. The HTML file looks as in the following,

  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">  
  2. <html>  
  3.   
  4. <head>  
  5.     <title></title>  
  6.     <link href="Bootstrap/css/bootstrap.css" rel="stylesheet" type="text/css" />  
  7.     <script src="dist/js/bootstrap.js" type="text/javascript"></script>  
  8. </head>  
  9.   
  10. <body>  
  11.     <form>  
  12.         <div>  
  13.             <label for="inputUserName">UserName</label>  
  14.             <input type="email" id="inputEmail" placeholder="UserName">  
  15.         </div>  
  16.         <div>  
  17.             <label for="inputPassword">Password</label>  
  18.             <input type="password" id="inputPassword" placeholder="Password">  
  19.         </div>  
  20.         <div class="checkbox">  
  21.             <label><input type="checkbox"> Remember me</label>  
  22.         </div>  
  23.         <button type="submit">Login</button>  
  24.     </form>  
  25. </body>  
  26.   
  27. </html>  
The HTML will render without Bootstrap as in the following,

Using default form layout

2. Using bootstrap CSS class="Horizontal Form"

In the horizontal form layout the label in the right is floated to the left to make them appear on the same line as form controls. To make a form that uses the Horizontal layout, 
  • Add .form-horizontal to the <form> element
  • Wrap labels and form controls in .control-group
  • Add .control-label to the <label> element

The list groups class is used to display lists of items in a beautiful manner. To do that you can use a list-group-item class with every item.

The HTML file looks as in the following,

  1. <form class="form-horizontal">  
  2.     <div class="form-group">  
  3.         <label for="inputUserName" class="control-label">  
  4. UserName</label>  
  5.         <input type="email" id="inputUserName" placeholder="UserName">  
  6.     </div>  
  7.     <div class="form-group">  
  8.         <label for="inputPassword" class="control-label">  
  9. Password</label>  
  10.         <input type="password" id="inputPassword" placeholder="Password">  
  11.     </div>  
  12.     <div class="checkbox">  
  13.         <label>  
  14. <input type="checkbox">  
  15. Remember me</label>  
  16.     </div>  
  17.     <button type="submit">  
  18. Login</button>  
  19. </form>  
The HTML will render without Bootstrap as in the following,

design

3. Using bootstrap CSS class="Inline Form"

To make a form where all the elements are inline just add Inline Form class with the form tag. You can do this by simply applying the Bootstrap's class Inline Form:

The HTML file looks as in the following,
  1. <form class="form-inline">  
  2.     <div class="form-group">  
  3.         <label for="inputUserName">  
  4. UserName</label>  
  5.         <input type="email" id="inputEmail" class="form-control" placeholder="UserName">  
  6.     </div>  
  7.     <div class="form-group">  
  8.         <label for="inputPassword">  
  9. Password</label>  
  10.         <input type="password" id="inputPassword" class="form-control" placeholder="Password">  
  11.     </div>  
  12.     <div class="checkbox">  
  13.         <label>  
  14. <input type="checkbox">  
  15. Remember me</label>  
  16.     </div>  
  17.     <button type="submit">  
  18. Login</button>  
  19. </form>  
The HTML will render without Bootstrap as in the following,

render without Bootstrap

For more details visit the following link - 

Question 28: How can you create a simple Navbar with Twitter Bootstrap?


Answer

You can create various variations of navbars quickly and without too much effort. The procedure is listed below:,
  • Create nav container with class .navigation and .navbar-default.
  • For better mobile display you need to create a container with the class .navbar-header. Inside this container, you can create a button to toggle the menu items using data-target.
  • Now, you can create your menu item list container. This container has the same id as data-target and the class is .collapse and .navbar-collapse.
  • Create menu list with ul li structure with the class .nav and .navbar-nav.

The following example will you show how to create a static navbar with basic navigation.

HTML Code

  1. <nav role="navigation" class="navbar navbar-default">  
  2.     <!-- Brand and toggle get grouped for better mobile display -->  
  3.     <div class="navbar-header">  
  4.         <button type="button" data-target="#navbarCollapse" data-toggle="collapse" class="navbar-toggle"> <span class="sr-only">Toggle navigation</span> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </button>  
  5.         <a href="#" class="navbar-brand">C# Corner</a> </div>  
  6.     <!-- Collection of nav links and other content for toggling -->  
  7.     <div id="navbarCollapse" class="collapse navbar-collapse">  
  8.         <ul class="nav navbar-nav">  
  9.             <li class="active"><a href="#">Home</a></li>  
  10.             <li><a href="#">Article</a></li>  
  11.             <li><a href="#">Technologies</a></li>  
  12.         </ul>  
  13.         <ul class="nav navbar-nav navbar-right">  
  14.             <li><a href="#">Login</a></li>  
  15.         </ul>  
  16.     </div>  
  17. </nav>  
Result

Display

Mobile Display

Mobile Display

For more details visit the following link - 

Question 29: Explain the history of Bootstrap and what languages are required to start Bootstrap.


Answer

History of Bootstrap - Bootstrap began as an internal project at Twitter hence sometimes Bootstrap is known as “Twitter Bootstrap”. Two guys named Mark Otto and Jacob Thornton got management approval to open source it.

Language Required when starting Bootstrap: Knowledge of HTML, CSS and JavaScript.

Now Start With Bootstrap: The coding starts with <!DOCTYPE html>, it shows the version of HTML that we use.
  1. <!DOCTYPE html>   
  2. <html>   
  3. …………..   
  4. ………..   
  5. </html>   
To ensure proper rendering and touch zooming, add the viewport meta tag to <Head>.
  1. <meta name="viewport" content="width=device-width, initial-scale=1">   
You can disable zooming capabilities on mobile devices by adding user-scalable=no to the viewport meta tag.
  1. <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">   
First program with Bootstrap,
  1. <!DOCTYPE html>  
  2. <html>  
  3.   
  4. <head>  
  5.     <title>First</title>  
  6.     <link rel="stylesheet" href="css/bootstrap.min.css">  
  7.     <style>  
  8.         body {  
  9.             background-color: #00F;  
  10.         }  
  11.           
  12.         h3 {  
  13.             color: #CCC;  
  14.         }  
  15.     </style>  
  16.     <meta name="viewport" content="width= device-width,initial-scale=1">  
  17.     <script src="js/bootstrap.min.js"></script>  
  18. </head>  
  19.   
  20. <body>  
  21.     <h3>HAPPY NEW YEAR 2015 We hope you are blessed with delight, fulfillment, and peace in this New Year. May the love and warmth carry you into the New Year with a joyful spirit and hopeful heart.On New Year's Day and every day, we wish you joy and fulfillment. May it brings health, prosperity and happiness to all.</h3>  
  22. </body>  
  23.   
  24. </html>  
Output

history of Bootstrap

For more details visit the following link - 

Question 30: How many types of screens can be in Grid System?


Answer

Bootstrap has the cool feature of being able to resize automatically based on the screen size of devices. We can organize content in multiple columns when using large screen devices but when we are using small screen devices we need to customize the columns to prevent loss of content and also to look good of our applications or websites.

Grid System

We have four types of screens
  • col-xs extra small screen size in devices such as smartphones (<768 px).
  • col-sm small screen size in devices such as tablets (>=768 px).
  • col-md medium screen size in devices such as laptops (>=992 px).
  • col-lg large screen size in devices such as computers (>=1200 px).

For more details visit the following link -

Question 31: What is Glyphicons in Bootstrap?


Answer

Glyphicons are icons we use to make our web page more attractive. For example, when we open a signup page then we see a user icon before a text box, this icon is glyphicon.

text box

Syntax

The syntax to add Glyphicons to a web page is,

<span class="glyphiconglyphicon-name"></span>

Some glyphicons are,

glyphicons

The following is an example of using it.
  1. <!DOCTYPE html>  
  2. <html>  
  3.   
  4. <head>  
  5.     <title>  
  6.         Glyphicons  
  7.     </title>  
  8.     <link rel="stylesheet" href="js/css/bootstrap.min.css">  
  9.     <script src="js/bootstrap.min.js"></script>  
  10.     <meta name="viewport" content="width= device-width, initial-scale=1">  
  11.     <style>  
  12.         body {  
  13.             text-align: center;  
  14.             color: #006;  
  15.             background-color: #CCC;  
  16.         }  
  17.     </style>  
  18. </head>  
  19.   
  20. <body>  
  21.     User Name <span class="glyphicon glyphicon-user"></span><br> Contact No <span class="glyphicon glyphicon-phone"></span><br> Address <span class="glyphicon glyphicon-home"></span><br> Download  
  22.     <a href="#">  
  23.         <span class="glyphicon glyphicon-download"></span></a><br>  
  24.     <button type="button" class="btn btn-default btn-md">   
  25. <span class="glyphicon glyphicon-cloud-upload">Upload</span>   
  26. </button>  
  27. </body>  
  28.   
  29. </html>   

Output

see output

For more details visit the following link -

Question 32: Give the syntax of buttons in Bootstrap.


Answer

Syntax of Button

<button type="button" class="btn btn-size">
<span class="glyphicon glyphicon-name"></span></button>
  • Default
  • Info
  • Primary
  • Danger
  • success
  • warning

Default Button Syntax

<button type=”button” class=”btn btn-default btn-size”>
Default
</button>

Info Button Syntax

<button type=”button” class=”btn btn-Info btn-size”>
Info
</button>

Primary Button Syntax

<button type=”button” class=”btn btn-primary btn-size”>
Primary
</button>

Danger Button Syntax

<button type=”button” class=”btn btn-Danger btn-size”>
Danger
</button>


Success Button Syntax

<button type=”button” class=”btn btn-Success btn-size”>
Success
</button>


Warning Button Syntax

<button type=”button” class=”btn btn-Warning btn-size”>
Warning
</button>


For more details visit the following link -

Question 33: Explain media objects in Bootstrap.


Answer

If you want to create a layout like blog comments that contain a left- or right-aligned image along with the textual content, you can do that easily through the newly introduced Bootstrap media component, like this.

HTML Code 
  1. <div class="media">  
  2.     <a href="#" class="pull-left">  
  3.         <img src="image.png" class="media-object">  
  4.     </a>  
  5.     <div class="media-body">  
  6.         <h4 class="media-heading">Vipin Kumar <small><i>Posted on September 02, 2014</i></small></h4>  
  7.         <p> The first part Getting started with Bootstrap provided a basic introduction of bootstrap and bootstrap layout.</p>  
  8.     </div>  
  9. </div>  
Result

media objects in Bootstrap

Note

You can also create a list of media objects or nested media objects using the media list component. It can be useful for comment threads or article lists.

For more details visit the following link - 

Question 34: What is Bootstrap Snippet Pack?


Answer

Bootstrap Snippet Pack has a collection of Bootstrap snippets for Visual Studio.

Very often, web developers need to minimize their development environment then go to the Bootstrap website to find a piece of HTML for a specific component.

Doing this all day reduces the developer productivity since he must switch back and forth between the browser and the development environment.

Fortunately, with Bootstrap Snippet Pack, a code snippet can be retrieved via Visual Studio.

To install the Bootstrap Snippet Pack from Visual Studio, go to Tools, then Extensions and Updates > Online > Search Bootstrap Snippet Pack.

Search Bootstrap Snippet Pack

Once installed from Visual Studio editor, hit CTL+K, CTL+X to bring in the snippet tool.

snippet tool

Then select Bootstrap and the component needed.

select Bootstrap

The Bootstrap Snippet Pack will automatically generate the required HTML.

Bootstrap Snippet Pack

For more details visit the following link - 

Question 35: How can you make an HTML File a Bootstrap Template?


Answer

For making this file a Bootstrap Template, after Downloading Bootstrap by the above procedure we will include Bootstrap CSS and JS files. We should include JS files at the bottom of the HTML page before closing <body> tag with the following code.
  1. <!DOCTYPE html>  
  2. <html lang="en">  
  3.   
  4. <head>  
  5.     <meta charset="utf-8">  
  6.     <title>Bootstrap Part1</title>  
  7.     <meta name="viewport" content="width=device-width,initial-scale=1">  
  8.     <link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">  
  9. </head>  
  10.   
  11. <body>  
  12.     <h1>Hello C# Corner</h1>  
  13.     <script src="js/jquery-2.1.4.min.js"></script>  
  14.     <script src="js/bootstrap.min.js"></script>  
  15. </body>  
  16.   
  17. </html>  
Now we will open the file in a browser by double clicking on it and see the output.

Output


see the output
For more details visit the following link - 

Question 36: What is Twitter Bootstrap? Explain with an example.


Answer

Twitter Bootstrap is a very popular and powerful front-end framework currently. It is self-generated for faster and easier web development. Twitter Bootstrap comes prepared with HTML, CSS and JavaScript for various web and user interface components. Bootstrap provides iconography, dropdowns, navigation, alerts, popovers and much more. This is covered in detail in the section Layout Components.

Creating Your First Web Page with Twitter Bootstrap

You have learned the structure and the purposes of Bootstrap files, now we'll create a basic Bootstrap template that includes everything we specified in the file structure. You will have made an HTML file that displays a "Welcome Bootstrap" message in your web browser.

Step 1

Creating a Basic HTML File.

Open up your code editor and create a new HTML file. Start with an empty window and type the following code,
  1. <!DOCTYPE html >  
  2. <html>  
  3.   
  4. <head>  
  5.     <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />  
  6.     <title>Basic HTML</title>  
  7. </head>  
  8.   
  9. <body>  
  10.     <h1>Welcome Bootstrap</h1>  
  11. </body>  
  12.   
  13. </html>  
Result

Creating a Basic HTML File

Step 2

Making this HTML File a Bootstrapped Template

To make this HTML file a Bootstrapped template, just include the appropriate Bootstrap CSS and JavaScript files.

Note

You should include JavaScript files at the bottom of the page; before closing the <body> tag (in other words </body>) to improve the performance of your web pages.
  1. <!DOCTYPE html >  
  2. <html>  
  3.   
  4. <head>  
  5.     <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />  
  6.     <title>HTML with Bootstrap</title>  
  7.     <!-- compiled and minified CSS -->  
  8.     <link rel="stylesheet" href="css/bootstrap.min.css">  
  9.     <!-- Optional theme -->  
  10.     <link rel="stylesheet" href="css/bootstrap-theme.min.css">  
  11. </head>  
  12.   
  13. <body>  
  14.     <h1>Welcome Bootstrap</h1>  
  15.     <!-- compiled and minified JavaScript -->  
  16.     <script type="text/javascript" src="js/bootstrap.min.js"></script>  
  17. </body>  
  18.   
  19. </html>  
Result

Creating a Basic HTML File

For more details visit the following link - 

Question 37: Explain Validation States with Twitter Bootstrap?


Answer

Bootstrap provides an easy-to-use and powerful mechanism for styling input controls to present various validation states. Bootstrap includes validation styles for error, warning and success messages. To use, just add the appropriate class to the surrounding .form-group.

The following shows Twitter Bootstrap Form Validation States.

HTML Code
  1. <form class="form-horizontal">  
  2.     <div class="form-group has-success">  
  3.         <label class="col-xs-2 control-label" for="inputSuccess">Username</label>  
  4.         <div class="col-xs-10">  
  5.             <input type="text" id="inputSuccess" class="form-control" placeholder="Input with success">  
  6.             <span class="help-block">Username is available</span>  
  7.         </div>  
  8.     </div>  
  9.     <div class="form-group has-warning">  
  10.         <label class="col-xs-2 control-label" for="inputWarning">Password</label>  
  11.         <div class="col-xs-10">  
  12.             <input type="password" id="inputWarning" class="form-control" placeholder="Input with warning">  
  13.             <span class="help-block">Password strength: Weak</span>  
  14.         </div>  
  15.     </div>  
  16.     <div class="form-group has-error">  
  17.         <label class="col-xs-2 control-label" for="inputError">Email</label>  
  18.         <div class="col-xs-10">  
  19.             <input type="email" id="inputError" class="form-control" placeholder="Input with error">  
  20.             <span class="help-block">Please enter a valid email address</span>  
  21.         </div>  
  22.     </div>  
  23. </form>  
Result

Making this HTML File

For more details visit the following link – 

Question 38: How do you create panels with Twitter Bootstrap?


Answer

Sometimes you might need to put your content in a box for a certain reason. In such a condition we can use panel components. In the most basic form the panel component applies a border and padding around the content. The following example will you show how to create simple panels.

HTML Code
  1. <div class="panel panel-default">   
  2. <div class="panel-body">Look, I'm in a panel!</div>   
  3. </div>   
Result

Validation States

You can also add a heading to your panel with the .panel-heading class.

HTML Code
  1. <div class="panel panel-default">  
  2.     <div class="panel-heading">Heading Page</div>  
  3.     <div class="panel-body">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec bibendum, leo vel venenatis finibus, purus nisl varius arcu, vel pulvinar turpis sapien at sapien. </div>  
  4. </div> 
Result

see result

Panels with Contextual States

In Twitter Bootstrap you can also add contextual classes like .panel-primary, .panel-success, .panel-info, .panel-warning, or .panel-danger on the panel components to make it more meaningful and to draw the attention of the user.

HTML Code
  1. <div class="panel panel-primary">  
  2.     <div class="panel-heading">  
  3.         <h3 class="panel-title">Primary</h3>  
  4.     </div>  
  5.     <div class="panel-body">The requested page has been permanently moved to a new location.</div>  
  6. </div>  
  7. <div class="panel panel-success">  
  8.     <div class="panel-heading">  
  9.         <h3 class="panel-title">Success</h3>  
  10.     </div>  
  11.     <div class="panel-body">The server successfully processed the request.</div>  
  12. </div>  
  13. <div class="panel panel-info">  
  14.     <div class="panel-heading">  
  15.         <h3 class="panel-title">info</h3>  
  16.     </div>  
  17.     <div class="panel-body">The client should continue with its request.</div>  
  18. </div>  
  19. <div class="panel panel-warning">  
  20.     <div class="panel-heading">  
  21.         <h3 class="panel-title">Warning</h3>  
  22.     </div>  
  23.     <div class="panel-body">The request cannot be fulfilled due to bad syntax.</div>  
  24. </div>  
  25. <div class="panel panel-danger">  
  26.     <div class="panel-heading">  
  27.         <h3 class="panel-title">Danger</h3>  
  28.     </div>  
  29.     <div class="panel-body">The server is temporarily unable to handle the request.</div>  
  30. </div>  
Result

create panels

For more details visit the following link - 

Question 39: How can you customize the CSS of Bootstrap?


Answer

Customize:

Contextual States

customize CSS of Bootstrap

Here you can customize you CSS of Bootstrap like color, border, font size, font style and many more. And at the bottom of this page, there is a compile and download button that will download the Bootstrap files to your local machine.

When you download the file, extract this file and you will see this.

download

Just copy them to the root directory of your web application.

For more details visit the following link -

Question 40: What is Twitter Bootstrap Pagination?


Answer - Pagination is the process of organizing content by dividing it into separate pages. The following example shows you how to create various types of pagination.

HTML Code
  1. <h3> Simple Pagination </h3>  
  2. <ul class="pagination">  
  3.     <li><a href="#">«</a></li>  
  4.     <li><a href="#">1</a></li>  
  5.     <li><a href="#">2</a></li>  
  6.     <li><a href="#">3</a></li>  
  7.     <li><a href="#">4</a></li>  
  8.     <li><a href="#">5</a></li>  
  9.     <li><a href="#">»</a></li>  
  10. </ul>  
  11. <h3> Pagination with Disabled and Active States </h3>  
  12. <ul class="pagination">  
  13.     <li class="disabled"><a href="#">«</a></li>  
  14.     <li class="active"><a href="#">1</a></li>  
  15.     <li><a href="#">2</a></li>  
  16.     <li><a href="#">3</a></li>  
  17.     <li><a href="#">4</a></li>  
  18.     <li><a href="#">5</a></li>  
  19.     <li><a href="#">»</a></li>  
  20. </ul>  
  21. <h3>Different Sizes of Pagination</h3>  
  22. <!-- Larger pagination -->  
  23. <ul class="pagination pagination-lg">  
  24.     <li><a href="#">«</a></li>  
  25.     <li><a href="#">1</a></li>  
  26.     <li><a href="#">2</a></li>  
  27.     <li><a href="#">3</a></li>  
  28.     <li><a href="#">4</a></li>  
  29.     <li><a href="#">5</a></li>  
  30.     <li><a href="#">»</a></li>  
  31. </ul>  
  32. <!-- Default pagination -->  
  33. <ul class="pagination">  
  34.     <li><a href="#">«</a></li>  
  35.     <li><a href="#">1</a></li>  
  36.     <li><a href="#">2</a></li>  
  37.     <li><a href="#">3</a></li>  
  38.     <li><a href="#">4</a></li>  
  39.     <li><a href="#">5</a></li>  
  40.     <li><a href="#">»</a></li>  
  41. </ul>  
  42. <!-- Smaller pagination -->  
  43. <ul class="pagination pagination-sm">  
  44.     <li><a href="#">«</a></li>  
  45.     <li><a href="#">1</a></li>  
  46.     <li><a href="#">2</a></li>  
  47.     <li><a href="#">3</a></li>  
  48.     <li><a href="#">4</a></li>  
  49.     <li><a href="#">5</a></li>  
  50.     <li><a href="#">»</a></li>  
  51. </ul>  
Result

download the file

Twitter Bootstrap Pager

In Bootstrap you can create a pager (Previous and Next links) on your website. For creating a pager with Bootstrap you can add a Bootstrap class .pager in the ul li structure.

HTML Code
  1. <ul class="pager">  
  2.     <li><a href="#">Previous</a></li>  
  3.     <li><a href="#">Next</a></li>  
  4. </ul>  
Result

Twitter Bootstrap Pager

Note

You can create an alignment of the pager using the .previous and .next class and you can disable the links using the .disable class.

For more details visit the following link - 

Question 41: What is a Bootstrap Breadcrumb?


Answer

A breadcrumb is a navigation scheme that indicates the user's location in a website or web application. The following example shows how to create breadcrumbs.

HTML Code
  1. <ul class="breadcrumb">  
  2.     <li><a href="#">Home</a></li>  
  3.     <li><a href="#">Products</a></li>  
  4.     <li class="active">Accessories</li>  
  5. </ul>  
Result

bootstrap breadcrumb

For more details visit the following link - 

Question 42: What are Bootstrap Badges?


Answer - Badges are small and simple components for displaying an indicator or to count some sort of number. This is very useful for mail count and notification etc.

Example
  1. <html>  
  2.   
  3. <head>  
  4.     <title>Example of Badges</title>  
  5.     <link href="bootstrap.css" rel="stylesheet">  
  6. </head>  
  7.   
  8. <body>  
  9.     <div class="Container">  
  10.         <div class="Row">  
  11.             <div class="Span">  
  12.                 <p><span class="badge">1</span></p>  
  13.                 <p><span class="badge badge-success">2</span></p>  
  14.                 <p><span class="badge badge-warning">4</span></p>  
  15.                 <p><span class="badge badge-important">6</span></p>  
  16.                 <p><span class="badge badge-info">8</span></p>  
  17.                 <p><span class="badge badge-inverse">10</span></p>  
  18.             </div>  
  19.         </div>  
  20.     </div>  
  21. </body>  
  22.   
  23. </html>  
Output

bootstrap badges

For more details visit the following link - 

Question 43: How can you create a Header using Bootstrap?


Answer

Using Twitter Bootstrap, you may create static navigation menus. To create a menu using Bootstrap open up the bootstrap.css file and check out the CSS class navbar-nav. The HTML file looks as in the following,
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">  
  2.   
  3. <html xmlns="http://www.w3.org/1999/xhtml">  
  4.   
  5. <head>  
  6.     <title></title>  
  7.     <script src="Scripts/jquery-1.4.1.min.js" type="text/javascript"></script>  
  8.     <link href="Bootstrap/css/bootstrap.css" rel="stylesheet" type="text/css" />  
  9.     <script src="Bootstrap/js/bootstrap.min.js" type="text/javascript"></script>  
  10. </head>  
  11.   
  12. <body>  
  13.     <div class="Container">  
  14.         <ul class="nav navbar-nav">  
  15.             <li><a href="#">Home</a></li>  
  16.             <li><a href="#about">Technologies</a></li>  
  17.             <li><a href="#contact">Article</a></li>  
  18.             <li><a href="#contact">blog</a></li>  
  19.             <li><a href="#contact">News</a></li>  
  20.         </ul>  
  21.     </div>  
  22. </body>  
  23.   
  24. </html>  
The HTML will be rendered with Bootstrap as in the following,

create a Header using Bootstrap

For more details visit the following link - 

Question 44: How can you create a Footer using Bootstrap?


Answer

Using Twitter Bootstrap, you may create static footer menus. To create a footer using Bootstrap open up the bootstrap.css file and check out the following CSS class and update it with the following code. 
  1. .container   
  2. {  
  3.     width100 % ;  
  4. }  
  5. .text - muted  
  6. {  
  7.     color: Black;  
  8.     background - colorred;  
  9.     height40 px;  
  10.     text - align: center;  
  11. }  
The HTML file looks as in the following,
  1. <div id="footer">  
  2.     <div class="container">  
  3.         <p class="text-muted credit">  
  4.             CONTACT US PRIVACY POLICY TERMS & CONDITIONS SITEMAP</p>  
  5.     </div>  
  6.     lt;/div>  
The HTML will be rendered with Bootstrap as in the following,

rendered with Bootstrap

For more details visit the following link - 

Question 45: How can you create Rating Control with Bootstrap?


Answer

Step 1

Download the CSS and JavaScript files from github.com.

Step 2

Open your Visual Studio, then add your downloaded file into your project then add index.aspx page and call your necessary files within the head tag from that downloaded folder.
  1. <head runat="server">  
  2.     <title></title>  
  3.     <link href="Bootstrap/css/bootstrap.min.css" rel="stylesheet" />  
  4.     <link href="Bootstrap/css/star-rating.css" rel="stylesheet" />  
  5.     <script src="http://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>  
  6.     <script src="Bootstrap/js/star-rating.js"></script>  
  7. </head>  
Step 3

Now call your rating control.
  1. <div class="row">  
  2.     <div class="col-lg-12">  
  3.   
  4.         <input id="input-21a" value="0" type="number" class="rating" data-symbol="*" min=0 max=5 step=0.5 data-size="xl">  
  5.         <hr>  
  6.         <input id="input-21b" type="number" class="rating" min=0 max=5 step=0.5 data-glyphicon="false" data-star-captions="{}" data-default-caption="{rating} Stars" data-size="lg">  
  7.         <hr>  
  8.         <input id="input-21c" value="0" type="number" class="rating" min=0 max=8 step=0.5 data-size="xl" data-stars="8">  
  9.         <hr>  
  10.         <input id="input-21d" value="2" type="number" class="rating" min=0 max=5 step=0.5 data-size="sm">  
  11.         <hr>  
  12.         <input id="input-21e" value="0" type="number" class="rating" min=0 max=5 step=0.5 data-size="xs">  
  13.         <hr>  
  14.     </div>  
  15. </div>  
Here, value is your filled start on page load, min is the minimum star value, max is the maximum star or maximum rating, data-size is your rating control size.

Step 4

Now we can see how to get the rated value from this rating control using jQuery as in the following,
  1. <script>  
  2.     $(document).ready(function()   
  3.     {  
  4.         $("#input-21b").on("rating.change", function(event, value, caption)   
  5.         {  
  6.             alert("You rated: " + value + " = " + $(caption).text());  
  7.         });  
  8.     });  
  9. </script>  
Step 5

Let's see how to get the rated value from code behind in C#. Add one hidden field in your design page and assign your rated value into your hidden field.

<asp:HiddenField ID="hdfRatingValue" runat="server" />

Now assign your rated value into your hidden field. Let's see how to do this using jQuery.
  1. <script>  
  2.     $(document).ready(function()   
  3.     {  
  4.         $("#input-21b").on("rating.change", function(event, value, caption)   
  5.         {  
  6.   
  7.             var ratingValue = $('#<%=hdfRatingValue.ClientID%>').val();  
  8.             ratingValue = value;  
  9.             alert(ratingValue);  
  10.         });  
  11.     });  
  12. </script>  
Now you can get the rating value from code behind. Type hdfRating.value and save your value to the database.

Full Example
  1. <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="index.aspx.cs" Inherits="RatingControl.index" %>  
  2.   
  3.     <!DOCTYPE html>  
  4.   
  5.     <html xmlns="http://www.w3.org/1999/xhtml">  
  6.   
  7.     <head runat="server">  
  8.         <title></title>  
  9.         <link href="Bootstrap/css/bootstrap.min.css" rel="stylesheet" />  
  10.         <link href="Bootstrap/css/star-rating.css" rel="stylesheet" />  
  11.         <script src="http://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>  
  12.         <script src="Bootstrap/js/star-rating.js"></script>  
  13.   
  14.         <script>  
  15.             $(document).ready(function() {  
  16.                 $("#input-21b").on("rating.change", function(event, value, caption) {  
  17.   
  18.                     var ratingValue = $('#<%=hdfRatingValue.ClientID%>').val();  
  19.                     ratingValue = value;  
  20.                     alert(ratingValue);  
  21.                 });  
  22.             });  
  23.         </script>  
  24.     </head>  
  25.   
  26.     <body>  
  27.         <form id="form1" runat="server">  
  28.             <div>  
  29.   
  30.                 <div class="row">  
  31.                     <div class="col-lg-12">  
  32.   
  33.                         <input id="input-21a" value="0" type="number" class="rating" data-symbol="*" min=0 max=5 step=0.5 data-size="xl">  
  34.                         <hr>  
  35.                         <input id="input-21b" type="number" class="rating" min=0 max=5 step=0.5 data-glyphicon="false" data-star-captions="{}" data-default-caption="{rating} Stars" data-size="lg">  
  36.                         <hr>  
  37.                         <input id="input-21c" value="0" type="number" class="rating" min=0 max=8 step=0.5 data-size="xl" data-stars="8">  
  38.                         <hr>  
  39.                         <input id="input-21d" value="2" type="number" class="rating" min=0 max=5 step=0.5 data-size="sm">  
  40.                         <hr>  
  41.                         <input id="input-21e" value="0" type="number" class="rating" min=0 max=5 step=0.5 data-size="xs">  
  42.                         <hr>  
  43.                     </div>  
  44.                 </div>  
  45.   
  46.             </div>  
  47.             <asp:HiddenField ID="hdfRatingValue" runat="server" />  
  48.         </form>  
  49.     </body>  
  50.   
  51.     </html>  
CS Code
  1. using System;  
  2. using System.Collections.Generic;  
  3. using System.Linq;  
  4. using System.Web;  
  5. using System.Web.UI;  
  6. using System.Web.UI.WebControls;  
  7.   
  8. namespace RatingControl   
  9. {  
  10.     public partial class index: System.Web.UI.Page   
  11.     {  
  12.         protected void Page_Load(object sender, EventArgs e)  
  13.         {  
  14.   
  15.         }  
  16.         public void saveRating()  
  17.         {  
  18.             string val = hdfRatingValue.Value;  
  19.         }  
  20.     }  
  21. }  
Output

create Rating Control
For more details visit the following link - 

Question 46: Explain File Structure of Bootstrap.


Answer

After downloading the Bootstrap files, unzip the compressed folder to see the structure. You'll find the following file structure and contents.

File Structure of Bootstrap

You can see that the compiled version of Bootstrap provides compiled CSS and JavaScript files (bootstrap.*), as well as compiled and minified CSS and JavaScript (bootstrap.min.*).

There are four font files (glyphicons-halflings-regular.*) inside the fonts folder. These fonts files includes 200 icons from the Glyphicon Halflings set.

For more details visit the following link -

Question 47: Explain Bootstrap Sortable.


Answer

Bootstrap Sortable is a jQuery extension for Bootstrap that adds the capability of sorting rows of your Bootstrap tables.

Features
  • Sorts table data alphabetically.
  • Sorts table data by numbers.
  • Sorts table data by dates. (Requires Momont.js).
  • Allows disabling sorting for a specific table column.

Botstrap Sortable

For more details visit the following link -

Question 48: How can we make Customize Buttons?


Answer

To make Customize Buttons more attractive than default buttons using Bootstrap, open the bootstrap.css file and check out the following Bootstrap CSS class. 
  1. btn-default
  2. btn-success
  3. btn-info
  4. btn-warning
  5. btn-danger
  6. btn-sm

1. Using Bootstrap CSS class="btn-default"

Now first we use the btn-default clsss. Now open the bootstrap.css file and find the btn-default class. It looks like this,

  1. .btn-default {  
  2. background-color#FFFFFF;  
  3. border-color#CCCCCC;  
  4. color#333333;  
The HTML file looks as in the following,
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">  
  2. <html>  
  3.   
  4. <head>  
  5.     <title></title>  
  6.     <script src="Scripts/jquery-1.4.1.min.js" type="text/javascript"></script>  
  7.     <link href="Bootstrap/css/bootstrap.css" rel="stylesheet" type="text/css" />  
  8.     <script src="Bootstrap/js/bootstrap.min.js" type="text/javascript"></script>  
  9.     <script src="Bootstrap/js/bootstrap.min.js" type="text/javascript"></script>  
  10.     <script src="Bootstrap/js/bootstrap.js" type="text/javascript"></script>  
  11.     <style>  
  12.   
  13.     </style>  
  14. </head>  
  15.   
  16. <body>  
  17.     <button type="button">  
  18. Default</button>  
  19.     <button type="button" class="btn-default">  
  20. btn-default Class</button>  
  21. </body>  
  22.   
  23. </html>  
The HTML will be rendered with Bootstrap as in the following:

HTML will be rendered with Bootstrap

2. Using bootstrap CSS classbtn-info, btn-warning, btn-danger, btn-sm

The HTML file looks as in the following,
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">  
  2. <html>  
  3.   
  4. <head>  
  5.     <title></title>  
  6.     <script src="Scripts/jquery-1.4.1.min.js" type="text/javascript"></script>  
  7.     <link href="Bootstrap/css/bootstrap.css" rel="stylesheet" type="text/css" />  
  8.     <script src="Bootstrap/js/bootstrap.min.js" type="text/javascript"></script>  
  9.     <script src="Bootstrap/js/bootstrap.min.js" type="text/javascript"></script>  
  10.     <script src="Bootstrap/js/bootstrap.js" type="text/javascript"></script>  
  11.     <style>  
  12.   
  13.     </style>  
  14. </head>  
  15.   
  16. <body>  
  17.     <button type="button">  
  18. Default</button>  
  19.     <br />  
  20.     <br />    
  21.     <button type="button" class="btn-default">  
  22. btn-default Class</button>  
  23.     <br />  
  24.     <br />    
  25.     <button type="button" class="btn-success">  
  26. btn-success Class</button>  
  27.     <br />  
  28.     <br />    
  29.     <button type="button" class="btn-info">  
  30. btn-info Class</button>  
  31.     <br />  
  32.     <br />    
  33.     <button type="button" class="btn-warning">  
  34. btn-warning Class</button>  
  35.     <br />  
  36.     <br />    
  37.     <button type="button" class="btn-danger">  
  38. btn-danger Class</button>  
  39.     <br />  
  40.     <br />    
  41.     <button type="button" class="btn-sm">  
  42. btn-sm Class</button>  
  43. </body>  
  44.   
  45. </html>  
The HTML will be rendered with Bootstrap as in the following,

result

For more details visit the following link - 

Question 49: Explain Alignment Classes in Bootstrap.


Answer

Alignment classes are used to align the text.

Example 
  1. <div class="container">  
  2.     <divclassdivclass="row">  
  3.         <div class="col-lg-12 h1 text-center">Alignment Classes</div>  
  4. </div>  
  5. <div class="row">  
  6.     <!--Here style for paragraph -->  
  7.     <div class="col-xs-12">  
  8.         <p class="text-left">Left Text</p>  
  9.         <p class="text-center">Centered Text</p>  
  10.         <p class="text-right">Right Text</p>  
  11.         <p class="text-justify">Justified Text</p>  
  12.         <p class="text-nowrap">No Wrap Text</p>  
  13.     </div>  
  14. </div>  
  15. </div>  
Block quotes

Block quotes - Quoting block of another source content into your content

Use a Footer tag for naming the source,
  1. <divclassdivclass="container">  
  2.     <divclassdivclass="row">  
  3.         <divclassdivclass="col-lg-12 h1 text-center">Blockquotes and Footer</div>  
  4.   
  5.             </div>  
  6.             <divclassdivclass="row">  
  7.                 <!--Here style for paragraph -->  
  8.                 <divclassdivclass="col-xs-12">  
  9.                     <blockquote>Learning Bootstrap Step by Step</blockquote>  
  10.                     <footer>- http://getbootstrap.com/css</footer>  
  11.                     </div>  
  12.   
  13.                     </div>  
  14.                     </div>  
run
For more details visit the following link - 

Question 50: How can you create a panel group?


Answer

We can group many panels together, by wrapping a <div> with class .panel-group around them. The.panel-group class clears the bottom-margin of each panel.

Creating Panel Group

In this example we will create Panels and Group it by using .panel-group class by writing the following code.
  1. <DOCTYPE html>  
  2.   
  3.     <html lang="en">  
  4.   
  5.     <head>  
  6.         <meta charset="utf-8">  
  7.         <title>Bootstrap Part7</title>  
  8.         <meta name="viewport" content="width=device-width,initial-scale=1">  
  9.         <link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">  
  10.     </head>  
  11.   
  12.     <body>  
  13.         <div class="container">  
  14.             <h2>Bootstrap Panel Group</h2>  
  15.             <!--Panel Group Start-->  
  16.             <div class="panel-group">  
  17.                 <!--Panel 1 Start-->  
  18.                 <div class="panel panel-default">  
  19.                     <div class="panel-heading">Panel 1 Heading</div>  
  20.                     <div class="panel-body">Panel Content</div>  
  21.                 </div>  
  22.                 <!--Panel 1 End-->  
  23.                 <!--Panel 2 Start-->  
  24.                 <div class="panel panel-default">  
  25.                     <div class="panel-heading">Panel 2 Heading</div>  
  26.                     <div class="panel-body">Panel Content</div>  
  27.                 </div>  
  28.                 <!--Panel 2 End-->  
  29.                 <!--Panel 3 Start-->  
  30.                 <div class="panel panel-default">  
  31.                     <div class="panel-heading">Panel 3 Heading</div>  
  32.                     <div class="panel-body">Panel Content</div>  
  33.                 </div>  
  34.                 <!--Panel 3 End-->  
  35.                 <!--Panel 4 Start-->  
  36.                 <div class="panel panel-default">  
  37.                     <div class="panel-heading">Panel 4 Heading</div>  
  38.                     <div class="panel-body">Panel Content</div>  
  39.                 </div>  
  40.                 <!--Panel 4 End-->  
  41.             </div>  
  42.             <!--Panel Group End-->  
  43.         </div>  
  44.         <script src="js/jquery-2.1.4.min.js"></script>  
  45.         <script src="js/bootstrap.min.js"></script>  
  46.     </body>  
  47.   
  48.     </html>  
Output

Output

For more details visit the following link - 

Read my free e-book on .NET Interview Questions and Answers,

.NET Interview Questions and Answers

Thanks for reading this article -- follow me and stay tuned with me on C# corner for more new updates.

More Interview Questions