This section includes InterviewSolutions, each offering curated multiple-choice questions to sharpen your knowledge and support exam preparation. Choose a topic below to get started.
| 51. |
How to change the size of Form controls in Bootstrap |
|
Answer» Use the CLASSES .input-lg and .input-sm to change the size of form controls in Bootstrap: The following is an example: <!DOCTYPE html> <html lang="en"> <head> <title>Bootstrap Form Input Sizing</title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"> <SCRIPT src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script> </head> <body> <div class="container"> <h2>Sizing Form Input Controls</h2> <form> <div class="form-group"> <label for="inputdefault">Regular input size</label> <input class="form-control" id="inputdefault" type="text"> </div> <div class="form-group"> <label for="inputlg">Large input size</label> <input class="form-control input-lg" id="inputlg" type="text"> </div> <div class="form-group"> <label for="inputsm">Smaller input size</label> <input class="form-control input-sm" id="inputsm" type="text"> </div> </form> </div> </body> </html>The output displays regular, large and smaller inputs: |
|
| 52. |
How to create unequal columns in Bootstrap |
|
Answer» Since the TOTAL of columns is 12, we can easily create unequal columns. The Bootstrap Grid System displays 12 columns in a page. For unequal columns, we can display then as: col-sm-3 col-sm-6 col-sm-3Let us implement the above in our Bootstrap code: <!DOCTYPE html> <html lang="en"> <head> <TITLE>Bootstrap Example</title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link REL="stylesheet" href="HTTPS://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script> </head> <body> <div class="container-fluid"> <H1>Unequal Columns</h1> <p><strong>Note:</strong> Resize the web browser window to see the effect.</p> <div class="row"> <div class="col-sm-3" style="background-color:gray;">.col-sm-3</div> <div class="col-sm-6" style="background-color:orange;">.col-sm-6</div> <div class="col-sm-3" style="background-color:yellow;">.col-sm-3</div> </div> </div> </body> </html>The output displays the following when screen size is above 768px: |
|
| 53. |
Why the d-md-inline-flex class used in Bootstrap 4? |
|
Answer» CREATE an INLINE flexbox container for MEDIUM screen USING d-md-inline-flex class in Bootstrap. |
|
| 54. |
Does Bootstrap 3 used Flexbox? |
|
Answer» No, Bootstrap 4 came with the concept of Flexbox to HANDLE layout. Design flexible responsive layout structure using flexbox. The d-flex class is used in Bootstrap to set a flexbox container. LET us SEE an EXAMPLE wherein we are creating Flex Items: <!DOCTYPE html> <html lang="en"> <head> <title>Bootstrap Flexbox</title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"></script> </head> <body> <div class="container mt-3"> <H2>Flex in Bootstrap</h2> <p>Here are the Flex items:</p> <div class="d-flex p-3 bg-primary text-white"> <div class="p-2 bg-info">Item 1</div> <div class="p-2 bg-warning">Item 2</div> <div class="p-2 bg-danger">Item 3</div> </div> </div> </body> </html>The following is the output: |
|
| 55. |
How to make responsive image in Bootstrap? |
|
Answer» The role of responsive images is to adjust to all screen sizes whether its mobile, desktop or tablet: For responsive image, set the following: max-width: 100%; height: auto;Using the img-fluid CLASS gives you both the above functionalities and scales perfectly on changing the screen size. Here is an example that makes an image responsive: <!DOCTYPE html> <html LANG="EN"> <head> <title>Bootstrap Responsive Image</title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" HREF="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"></script> </head> <body> <div class="container"> <h2>Demo Image</h2> <p>The following image is responsive and will scale perfectly on different screen sizes.</p> <p><strong>Note:</strong> Resize the web BROWSER to check the effect.</p> <img class="img-fluid" src="https://d2o2utebsixu4k.cloudfront.net/media/images/7d7b2bef-2512-4a87-96cb-0bafd0da5048.jpg" alt="Chania" width="460" height="345"> </div> </body> </html>The output displays a responsive image. Resize the web browser to check the effect: |
|
| 56. |
Why the align-content-sm-end class used in Bootstrap 4? |
|
Answer» Align GATHERED ITEMS at the end on SMALL SCREEN using the align-content-sm-end CLASS in Bootstrap. |
|
| 57. |
How to change the background color of table rows or individual cells in Bootstrap |
|
Answer» The contextual classes are USED to change the BACKGROUND color of table rows or individual cells in Bootstrap 4. The FOLLOWING are the classes with the colors they represent:
Let us now see an example to change the background color in a table: <!DOCTYPE html> <html lang="en"> <head> <title>Bootstrap Contextual Classes</title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"></script> </head> <body> <div class="container"> <h2>Investor's Data</h2> <p>The following is the Investor's data:</p> <table class="table table-bordered"> <thead> <tr> <th>Company</th> <th>Investor</th> </tr> </thead> <tbody> <tr class="table-primary"> <td>ABC</td> <td>PQ</td> </tr> <tr class="table-danger"> <td>GHI</td> <td>VW</td> </tr> <tr class="table-warning"> <td>JKL</td> <td>EF</td> </tr> <tr class="table-active"> <td>RST</td> <td>IJ</td> </tr> <tr class="table-success"> <td>MNO</td> <td>KL</td> </tr> </tbody> </table> </div> </body> </html>Here is the output: |
|
| 58. |
How to display code with Bootstrap? |
|
Answer» To display code with Bootstrap, work with the <code> tag. With that, we can also use the <pre> tag. The <code> tag For inline code, use the <code> tag. Here, we are displaying a header file code: <!DOCTYPE html> <html lang="en"> <head> <title>Bootstrap Code</title> <meta charset="utf-8"> <meta NAME="VIEWPORT" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script> </head> <body> <div class="container mt-3"> <h2>C PROGRAMMING</h2> <p>The following is the header file for C language:</p> <code>#include <stdio.h></code> <p>The following is the header file for C++ language:</p> <code>#include <iostream></code> </div> </body> </html>The output displays code. In our case, it is only a header file: The <pre> tag If the code has multiple lines, then use the <pre> tag: <!DOCTYPE html> <html lang="en"> <head> <title>Bootstrap Code</title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script> </head> <body> <div class="container mt-3"> <h2>Codes </h2> <p>The following is the header file for C language:</p> <code>#include <stdio.h></code> <p>The following is the usage of fieldset ELEMENT:</p> <pre> <form> <fieldset> <legend>Details:</legend> Name: <input type="text"><br> EMAIL: <input type="text"><br> </fieldset> </form> </pre> </div> </body> </html>The output shows the code in multiple lines: |
|
| 59. |
Why do we use badges in Bootstrap? |
|
Answer» If you want to add additional information to your content, then use Badges in Bootstrap. Badges LOOKS like labels, but the corners of Badges are more rounded. If you have a newly launched product and you add the same on your website, then you can add a Badge there as it is “NEW”. To add a Badge, just add the following with the content of the Badge: <span class ="badge"> Content </span>Or you can ALSO use it for count of posts in a blog: <span class ="badge"> 20 </span>Let us see an example: <!DOCTYPE HTML> <html LANG="en"> <head> <title>Bootstrap Example</title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"></script> </head> <body> <div class="container"> <h2>Products</h2> <h3>Trousers<span class="badge badge-primary">New</span></h3> </div> </body> </html>The output displays a blue colored Badge, since we have used .badge-primary contextual class: We can change the color of Badge by adding other contextual classes like .badge-secondary, badge-info, badge-danger, .badge-warning, .badge-light, .badge-dark, etc. Let us see another example of colored badges: <!DOCTYPE html> <html lang="en"> <head> <title>Bootstrap Example</title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"></script> </head> <body> <div class="container"> <h2>Products</h2> <h3>Trousers<span class="badge badge-primary">New</span></h3> <h3>Laptop<span class="badge badge-secondary">New</span></h3> <h3>Headphone<span class="badge badge-info">New</span></h3> <h3>Bags<span class="badge badge-warning">Sold</span></h3> </div> </body> </html>The output: |
|
| 60. |
How can I animate a Progress Bar in Bootstrap? |
|
Answer» The .active class is used in Bootstrap to create an animated Progress Bar. To your already created ProgressBar, include the .active class with the other Progress Bar classes like: <div class="progress-bar progress-bar-success progress-bar-striped active" role="progressbar" aria-valuenow="90" aria-valuemin="0" aria-valuemax="100" style="width:90%"> 90% </div>The animation would only be visible if you have already set the Progress Bar to have strip lines as shown in the following example. Here, we have 4 Progress Bars and all are animated: <!DOCTYPE HTML> <html lang="en"> <head> <title>Bootstrap Example</title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link REL="stylesheet" HREF="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script> </head> <body> <div class="container"> <h2>App Performance</h2> <div class="progress"> <div class="progress-bar progress-bar-success progress-bar-striped active" role="progressbar" aria-valuenow="90" aria-valuemin="0" aria-valuemax="100" style="width:90%"> 90% </div> </div> <h2>App Crashes</h2> <div class="progress"> <div class="progress-bar progress-bar-warning progress-bar-striped active" role="progressbar" aria-valuenow="10" aria-valuemin="0" aria-valuemax="100" style="width:10%"> 10% </div> </div> <h2>App Errors</h2> <div class="progress"> <div class="progress-bar progress-bar-danger progress-bar-striped active" role="progressbar" aria-valuenow="20" aria-valuemin="0" aria-valuemax="100" style="width:20%"> 20% </div> </div> <h2>App Success Rate</h2> <div class="progress"> <div class="progress-bar progress-bar-info progress-bar-striped active" role="progressbar" aria-valuenow="75" aria-valuemin="0" aria-valuemax="100" style="width:75%"> 75% </div> </div> </div> </body> </html>The output DISPLAYED is animated: |
|
| 61. |
Which class is used to wrap flex items on medium screen size in Bootstrap? |
|
Answer» Wrap flex items on MEDIUM SCREEN size using the flex-md-wrap CLASS in BOOTSTRAP. |
|
| 62. |
Float an element to the right with Bootstrap |
|
Answer» Use the pull-right class in BOOTSTRAP to float an element to the right. Let us see an example wherein an element is displayed on the right: <!DOCTYPE html> <html lang="en"> <head> <title>Bootstrap Pull Right</title> <meta charset="utf-8"> <meta name="viewport" CONTENT="width=device-width, initial-scale=1"> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script> </head> <BODY> <div class="container"> <h2>Floating an element</h2> <div class="pull-right"> This is on the right! </div> </div> </body> </html>The output displays our <div> on the right: |
|
| 63. |
How to create responsive table in Bootstrap? |
|
Answer» With Bootstrap, you can easily create a responsive table using the table-responsive class. The example below displays a responsive table that adds a horizontal scrollbar for screen less than 992px wide. It looks the same above 992px. Note: Resize the web browser to check the effect <!DOCTYPE html> <html lang="en"> <head> <TITLE>Bootstrap Contextual CLASSES</title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css"> <SCRIPT src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"></script> </head> <body> <div class="container"> <h2>Match Timings DATA</h2> <p>The following are the details of the match timings for individuals:</p> <table class="table table-responsive"> <THEAD class="thead-dark"> <tr> <th>Event</th> <th>Timings</th> </tr> </thead> <tbody> <tr class="table-primary"> <td>Entry</td> <td>9AM</td> </tr> <tr class="table-primary"> <td>Session1</td> <td>9:30AM - 11:30AM</td> </tr> <tr class="table-primary"> <td>Lunch</td> <td>11:45AM - 12:15PM</td> </tr> <tr class="table-primary"> <td>Session2</td> <td>12:30PM - 2:30PM</td> </tr> <tr class="table-primary"> <td>Tea</td> <td>2:45PM - 3:00PM</td> </tr> <tr class="table-primary"> <td>Session3</td> <td>3:15PM - 5:15PM</td> </tr> <tr class="table-success"> <td>Presentation</td> <td>5:20PM - 5:45PM</td> </tr> <tr class="table-primary"> <td>Exit</td> <td>After 5:45PM</td> </tr> </tbody> </table> </div> </body> </html>The above displays the following responsive table: |
|
| 64. |
What is a Condensed Table in Bootstrap? |
|
Answer» To condense a table means to cut the row padding in half to shrink it. Here’s how you make a table condensed: <table CLASS="table table-condensed"> … </table>A regular table with border looks like this: However, a table with bordered and condensed class looks like this. You can easily spot the difference in padding i.e. the following table itself looks condensed: The below example displays how we can create a condensed table: <!DOCTYPE HTML> <html lang="en"> <head> <TITLE>BOOTSTRAP Condensed Table</title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script> </head> <body> <div class="container"> <h2>Rank</h2> <p>Rank of teams in Test Cricket</p> <table class="table table-bordered table-condensed"> <thead> <tr> <th>Team</th> <th>Rank</th> </tr> </thead> <tbody> <tr> <td>India</td> <td>1</td> </tr> <tr> <td>England</td> <td>2</td> </tr> <tr> <td>Australia</td> <td>3</td> </tr> <tr> <td>SOUTH Africa</td> <td>4</td> </tr> <tr> <td>Srilanka</td> <td>5</td> </tr> </tbody> </table> </div> </body> </html>The condensed table as our output looks like this: |
|
| 65. |
How to center Pills in Bootstrap? |
|
Answer» The .nav-justified class is used in Bootstrap to CENTER pills. The following is an example: <!DOCTYPE html> <html lang="en"> <head> <title>Bootstrap Pills</title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script> </head> <body> <div class="container"> <h3>Centered Pills</h3> <p><strong>Note:</strong> Resize the browser window to see the effect. Items LOOK stacked if the screen size if less than 768px</p> <ul class="nav nav-pills nav-justified"> <li class="ACTIVE"><a href="#">HOME</a></li> <li><a href="#">AboutUs</a></li> <li><a href="#">COMPANY</a></li> </ul> </div> </body> </html>The output when the screen size is less than 768px. The pills look stacked: The output when the screen size is more than 768px: |
|
| 66. |
How to display flex items horizontally in Bootstrap? |
|
Answer» With Bootstrap, it’s possible to display FLEX items horizontally using the .flex-row class. You need to use the following: <div class="d-flex flex-row bg-secondary mb-3">Above, we have used the contextual class “bg-secondary” for background color. Now, we will work on an example: <!DOCTYPE html> <html lang="en"> <head> <title>Bootstrap Example</title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link REL="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css"> <script SRC="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/js/bootstrap.min.js"></script> </head> <body> <div class="CONTAINER mt-3"> <h1>Student Name</h1> <div class="d-flex flex-row bg-primary mb-3"> <div class="p-2 bg-danger">Sehral</div> <div class="p-2 bg-primary">Fara</div> <div class="p-2 bg-dark">Kelly</div> <div class="p-2 bg-secondary">Gemma</div> <div class="p-2 bg-warning">Jessica</div> <div class="p-2 bg-primary">Lauren</div> </div> </div> </body> </html>The above aligns the flex items horizontally: To display flex items horizontally, use the flex-*-row class in Bootstrap. For difference screens, replace the * in the class name with the following: For large screen: flex-lg-rowFor medium size screen: flex-md-rowFor SMALL screen: flex-sm-row |
|
| 67. |
Why Media Object used in Bootstrap? |
|
Answer» To set an aligned object with content, use the Media Object. These objects can be image or video. The usage of media objects can be seen in the comment section of a website/ blog. The .media class and .media-body class is USED in Bootstrap to work with media objects. Float a media object using .media class, WHEREAS .media-body class place media content inside a child CONTAINER. The following is an example that creates a media object to align image with content: <!DOCTYPE html> <html LANG="en"> <head> <title>Bootstrap Example</title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"></script> </head> <body> <div class="container mt-3"> <h2>Learn</h2> <p>Here comes the article content...</p> <div class="media border p-3"> <img src="https://d2o2utebsixu4k.cloudfront.net/media/images/dfbac927-789d-4780-acdb-0eeceab17a17.jpg" alt="John Doe" class="mr-3 mt-3 rounded-square" style="width:90px;"> <div class="media-body"> <h4>Dev Ops</h4> <p>This is demo text! This is demo text! This is demo text! This is demo text! This is demo text! This is demo text! This is demo text!</p> </div> </div> </div> </body> </html>The following is the output that displays an image aligned on the left with content: If you want to align media object on the top, bottom, or middle POSITION, then you can use the flex. Nested media objects are also feasible in Bootstrap. |
|
| 68. |
Three types of Form Layouts in Bootstrap |
|
Answer» Form Layout in Bootstrap has the following three forms:
Let us learn about them one by one: Vertical Form This is the default form in Bootstrap. Let us see a code snippet to understand it: <!DOCTYPE html> <html lang="en"> <head> <title>Bootstrap Example</title> <meta CHARSET="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"> <script SRC="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script> </head> <body> <div class="container"> <h2>Vertical Form in Bootstrap</h2> <div class="form-group"> <label for="email">UserId (Email):</label> <input type="email" class="form-control" id="useremail"> </div> <div class="form-group"> <label for="pwd">Password:</label> <input type="password" class="form-control" id="pwd"> </div> </div> </body> </html>The above DISPLAYS the following vertical form as the output: Horizonal Form The form-horizonal class is used in Bootstrap for Horizontal form. The labels are ALIGNED horizontally next to the input field on large and medium screens. However, on small screens i.e. < 767px, it will get converted to a vertical form. The form would then look like labels on top of each input). Let us see a code to understand it: <!DOCTYPE html> <html lang="en"> <head> <title>Bootstrap Example</title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script> </head> <body> <div class="container"> <h2>Horizontal Form in Bootstrap</h2> <form class="form-horizontal" action=""> <div class="form-group"> <label class="control-label col-sm-2" for="email">UserId(Email):</label> <div class="col-sm-10"> <input type="email" class="form-control" id="useremail" placeholder="Enter email"> </div> </div> <div class="form-group"> <label class="control-label col-sm-2" for="pwd">Password:</label> <div class="col-sm-10"> <input type="password" class="form-control" id="pwd" placeholder="Enter password"> </div> </div> </form> </div> </body> </html>Here is the output when the screen size is below 767 px: Here is the output when the screen size is above 767 px: Inline Form Inline forms are the forms in which the elements are inline and left-aligned. For using it, add class .form-inline to the <form> tag. Let us see an example: <!DOCTYPE html> <html lang="en"> <head> <title>Bootstrap Example</title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script> </head> <body> <div class="container"> <h2>Inline Form in Bootstrap</h2> <form class="form-inline" action=""> <div class="form-group"> <label for="email">Email ADDRESS:</label> <input type="email" class="form-control" id="email"> </div> <div class="form-group"> <label for="pwd">Password:</label> <input type="password" class="form-control" id="pwd"> </div> <button type="submit" class="btn btn-default">Submit</button> </form> </div> </body> </html>Here is the output when the screen size is below 767 px: Here is the output when the screen size is above 767 px. All the elements are now inline and left-aligned |
|
| 69. |
Can a Progress Bar be created with different colors? |
|
Answer» Yes, we can easily create a Progress Bar with DIFFERENT colors using the contextual classes. The following are the contextual classes available for Progress Bar in Bootstrap:
For our example, let us create a green colored Progress Bar: <div class="progress"> <div class="progress-bar progress-bar-success" role="progressbar" aria-valuenow="80" aria-valuemin="0" aria-valuemax="100" style="width:80%"> <span class="sr-only">80%</span> </div> </div>The above displays the following green colored Progress Bar: Let us now create multiple Progress BARS with different colors. Here, we are displaying information about an app based on its PERFORMANCE, crashes and errors. For all this information, we have used three Progress Bars: <!DOCTYPE html> <html lang="en"> <head> <title>Bootstrap Example</title> <META charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script> </head> <body> <div class="container"> <h1>App Information</h1> <h2>App Performance</h2> <div class="progress"> <div class="progress-bar progress-bar-success" role="progressbar" aria-valuenow="90" aria-valuemin="0" aria-valuemax="100" style="width:90%"> 90% </div> </div> <h2>App Crashes</h2> <div class="progress"> <div class="progress-bar progress-bar-warning" role="progressbar" aria-valuenow="10" aria-valuemin="0" aria-valuemax="100" style="width:10%"> 10% </div> </div> <h2>App Errors</h2> <div class="progress"> <div class="progress-bar progress-bar-danger" role="progressbar" aria-valuenow="20" aria-valuemin="0" aria-valuemax="100" style="width:20%"> 20% </div> </div> </div> </body> </html>The output displays Progress Bars with different colors: |
|
| 70. |
How to create Navbar in Bootstrap? |
|
Answer» To create a Navbar in Bootstrap, use the .navbar class. For responsiveness, follow it with .navbar-expand class with the values: .navbar-expand -xl: Stack navbar vertically on extra large screen .navbar-expand -LG: Stack navbar vertically on large screen .navbar-expand -md: Stack navbar vertically on medium screen .navbar-expand -sm: Stack navbar vertically on small large screenNow, in a navbar, you have links, which a user can click and navigate. To add links, use class “.navbar-nav” and under that the <LI> elements should be with a .nav-item class as shown below: <ul class="navbar-nav"> <li class="nav-item"> <a class="nav-link" href="#">One</a> </li> <li class="nav-item"> <a class="nav-link" href="#">Two</a> </li> </ul>Let us SEE what we discussed above in the following example: <!DOCTYPE html> <html lang="en"> <head> <title>Bootstrap Navbar</title> <meta charset="utf-8"> <meta NAME="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"></script> </head> <body> <nav class="navbar navbar-expand-sm bg-light"> <ul class="navbar-nav"> <li class="nav-item"> <a class="nav-link" href="#">Home</a> </li> <li class="nav-item"> <a class="nav-link" href="#">Technology</a> </li> <li class="nav-item"> <a class="nav-link" href="#">Research</a> </li> <li class="nav-item"> <a class="nav-link" href="#">Entertainment</a> </li> <li class="nav-item"> <a class="nav-link" href="#">FESTIVALS</a> </li> <li class="nav-item"> <a class="nav-link" href="#">News</a> </li> </ul> </nav> </body> </html>The following is the output that display the navigation bar with 6 links: |
|
| 71. |
How to create striped table with Bootstrap? |
|
Answer» To CREATE a table in Bootstrap, use the .table class. However, to create a striped table, use the .table-stripped class. The striped table will have striped rows i.e. zebra striped rows. Here’s how you add a striped table: <table class="table table-striped"> … </table>The below example displays how we can create a striped table: <!DOCTYPE html> <html lang="en"> <head> <title>Bootstrap Striped Table</title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script> </head> <body> <div class="container"> <h2>Data</h2> <p>The following is the Investor's data:</p> <table class="table table-striped"> <thead> <tr> <th>Company</th> <th>Investor</th> </tr> </thead> <TBODY> <tr> <td>ABC</td> <td>PQ</td> </tr> <tr> <td>GHI</td> <td>VW</td> </tr> <tr> <td>JKL</td> <td>EF</td> </tr> <tr> <td>RST</td> <td>IJ</td> </tr> <tr> <td>MNO</td> <td>KL</td> </tr> </tbody> </table> </div> </body> </html>The above displays the below given output with striped rows (zebra striped). We have here 6 rows and 2 columns: |
|
| 72. |
How to create a responsive navbar in Bootstrap? |
|
Answer» Responsive feature can be easily added to a navbar. Create a default navbar and make it responsive. Now, WRAP the content in a <div> with collapse and navbar-collapse classes: <div class = "collapse navbar-collapse" id = "demo"> <ul class="NAV navbar-nav"> <li class="active"><a href="#">Home</a></li> <li><a href="#">AboutUs</a></li> <li><a href="#">Company</a></li> <li><a href="#">SERVICES</a></li> <li><a href="#">Contact</a></li> </ul> </div>Let us now see an example to create a responsive navbar following the above steps: <!DOCTYPE html> <html lang="en"> <head> <title>Bootstrap Responsive Navbar</title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script> </head> <body> <nav class="navbar navbar-default"> <div class="navbar-header"> <button type = "button" class = "navbar-toggle" data-toggle = "collapse" data-target = "#demo"> <span class = "icon-bar"></span> <span class = "icon-bar"></span> <span class = "icon-bar"></span> </button> <a class="navbar-brand" href="#">New Website</a> </div> <div class = "collapse navbar-collapse" id = "demo"> <ul class="nav navbar-nav"> <li class="active"><a href="#">Home</a></li> <li><a href="#">AboutUs</a></li> <li><a href="#">Company</a></li> <li><a href="#">Services</a></li> <li><a href="#">Contact</a></li> </ul> </div> </nav> </body> </html>The output shows the responsive menu: |
|
| 73. |
How do we add outline to Buttons in Bootstrap? |
|
Answer» To add OUTLINE to Buttons, Bootstrap 4 came up with some classes for outline buttons. For example, For a blue outline, use the .btn-outline-primary class. In the same way for red outline, use the .btn-outline-danger class. The output displays outline for Buttons: |
|
| 74. |
Center an element in Bootstrap |
|
Answer» The CENTER-block BOOTSTRAP class is useful in CHANGING the position of an element to center. The class APPLIES the following to center an element: display:block margin-right:auto margin-left:autoThe following is an example that floats an element in the center in Bootstrap 3: <!DOCTYPE html> <html> <head> <meta name="viewport" CONTENT="width=device-width, initial-scale=1"> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script> </head> <body> <div class="container"> <h2>Floating an element</h2> <div class="center-block" style="background-color:red;color: white;width:100px;"> This is in the center! </div> </div> </body> </html>The output: Bootstrap 4 came with the concept of flex. Using flex, you can easily center an element with.align-self-center class. |
|
| 75. |
How can I add footer to panel in Bootstrap |
|
Answer» To add a footer to panel in Bootstrap, use the .panel-footer class: <div class="panel-footer">Panel Footer </div>Let us see an example to add footer to panel: <!DOCTYPE HTML> <html lang="EN"> <head> <TITLE>Bootstrap Example</title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" HREF="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script> </head> <body> <div class="CONTAINER"> <h2>Panels in Bootstrap</h2> <div class="panel panel-default"> <div class="panel-heading">Panel Heading</div> <div class="panel-body">This is our Panel</div> <div class="panel-footer">Panel Footer</div> </div> </div> </body> </html>The output displays a footer in panel: |
|
| 76. |
Align components in Bootstrap |
|
Answer» Let’s say you have Dropdown component in Bootstrap to create Dropdown menus. The menus generally get displayed in the default format LIKE this: If you want to align the above component to the right, then it is possible with Bootstrap. To align the menus on your website, you can USE the .dropdown-MENU-right class. It aligns the dropdown menus on the right. The following is an example that aligns the menu to the right on clicking: <!DOCTYPE html> <html lang="en"> <head> <title>Bootstrap Menus ALIGNMENT</title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" HREF="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script> </head> <body> <div class = "container"> <h2>Football Teams</h2> <p>The following is the information about the teams:</p> <div class = "dropdown"> <button class = "btn btn-primary dropdown-toggle" type = "button" data-toggle="dropdown">Teams <span class = "caret"></span></button> <ul class = "dropdown-menu dropdown-menu-right"> <li><a href = "#">Real Madrid</a></li> <li><a href = "#">CSKA Moscow</a></li> <li><a href = "#">Manchester United</a></li> <li><a href = "#">Barcelona</a></li> </ul> </div> </div> </body> </html>The output: Above, we have created and set the menus on the right as shown below: <ul class = "dropdown-menu dropdown-menu-right"> <li><a href = "#">Real Madrid</a></li> <li><a href = "#">CSKA Moscow</a></li> <li><a href = "#">Manchester United</a></li> <li><a href = "#">Barcelona</a></li> </ul> |
|
| 77. |
What are Carets in Bootstrap? |
|
Answer» On dropdown MENUS, you may have seen an arrow icon. This is called carot arrow icon. Here’s an example: In BOOTSTRAP, you can easily create a carot icon USING the .caret class. The following is an example displaying dropdown menu with the carot arrow icon: <!DOCTYPE html> <html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script> </head> <body> <div class="container"> <H2>Popular Brands</h2> <div class="dropdown"> <button class="btn btn-primary dropdown-toggle" type="button" data-toggle="dropdown">Brands <span class="caret"></span></button> <ul class="dropdown-menu"> <li><a href="#">Kenstar</a></li> <li><a href="#">Samsung</a></li> <li><a href="#">Fastrack</a></li> <li><a href="#">Tanishq</a></li> <li><a href="#">Britannia</a></li> </ul> </div> </div> </body> </html>The OUTPUT: |
|
| 78. |
What does a default navbar consist of? |
|
Answer» The default navbar is a basic Navigation Bar that use the FOLLOWING class: class = "navbar navbar-default"With that, set role as navigation: <nav class = "navbar navbar-default" role = "navigation">Now, header class is added, which act as a container for LOGO or header. The logo is added using navbar-brand: <div class = "navbar-header"> <a class = "navbar-brand" href = "#">Knowledge Hut</a> </div>Let us see an example now: <!DOCTYPE html> <html lang="en"> <head> <TITLE>Bootstrap Example</title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script> </head> <body> <nav class="navbar navbar-default" role = "navigation"> <div class="container-fluid"> <div class="navbar-header"> <a class="navbar-brand" href="#">New WEBSITE</a> </div> <ul class="nav navbar-nav"> <li class="active"><a href="#">Home</a></li> <li><a href="#">AboutUs</a></li> <li><a href="#">Company</a></li> <li><a href="#">Services</a></li> <li><a href="#">Contact</a></li> </ul> </div> </nav> </body> </html>The output: |
|
| 79. |
Why the d-sm-flex class used in Bootstrap 4? |
|
Answer» Create a FLEXBOX CONTAINER for small screen USING the d-sm-flex CLASS in Bootstrap. |
|
| 80. |
What is a card in Bootstrap? |
|
Answer» On many WEBSITES, you may have seen cards with images that describes the profile of an author or contributor. Create these using cards in Bootstrap, which is a BORDERED box with some padding around it. Use the .card class to create a card in Bootstrap. With that, Bootstrap provides .card-body class to add content INSIDE it. Let US now learn how to create a basic card in Bootstrap: <!DOCTYPE html> <html lang="en"> <head> <title>Bootstrap Card</title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" HREF="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"></script> </head> <body> <div class="container"> <h2>Card</h2> <div class="card"> <div class="card-body">Card Body</div> </div> </div> </body> </html>The output displays the following card: With Bootstrap, you can also add card titles. |
|
| 81. |
Container-fluid vs Container in Bootstrap |
|
Answer» Container (Fixed-Width) USE the container element when you want fixed-width which is responsive. Include it like this: <!DOCTYPE html> <html lang="en"> <head> <title>Bootstrap Demo</title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css"> <SCRIPT src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"></script> </head> <body> <div class="container"> <h1>Demo Page</h1> <p>The .container class provides a fixed width container.</p> </div> </body> </html>Container Fluid (Full-Width) Use the container-fluid element to provide a full-width container that spans the ENTIRE width of the viewport: Include it like this: <!DOCTYPE html> <html lang="en"> <head> <title>Bootstrap Demo</title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"></script> </head> <body> <div class="container-fluid"> <h1>Demo Page</h1> <p>The .container-fluid class provides a full width container, spanning the entire width of the viewport.</p> </div> </body> </html>The following describes the difference between both the LAYOUTS: |
|
| 82. |
Pagination in Bootstrap? |
|
Answer» With Bootstrap, you can easily add Pagination on any web page. This is useful if you have a lot of linked posts and pages. Some classes in Bootstrap are useful in creating a basic pagination. Let us see them below: To create a basic pagination, you need to use the <ul> tag. Include the .pagination class to this <ul> and then add the .page-item to each <li> tag. The following pagination has active post as 2nd. We have active USING the “.active” class to display the current post/ page: <!DOCTYPE HTML> <html lang="EN"> <head> <title>Bootstrap Navbar</title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"></script> </head> <body> <div class="container"> <h2>Post 2</h2> <p>The following is a demo line.</p> <p>The following is a demo line.</p> <p>The following is a demo line.</p> <p>The following is a demo line.</p> <ul class="pagination"> <li class="page-item"><a class="page-link" href="#">Previous</a></li> <li class="page-item"><a class="page-link" href="#">1</a></li> <li class="page-item active"><a class="page-link" href="#">2</a></li> <li class="page-item"><a class="page-link" href="#">3</a></li> <li class="page-item"><a class="page-link" href="#">4</a></li> <li class="page-item"><a class="page-link" href="#">5</a></li> <li class="page-item"><a class="page-link" href="#">6</a></li> <li class="page-item"><a class="page-link" href="#">Next</a></li> </ul> </div> </body> </html>The output below displays demo content and pagination with next/ previous links as well: |
|
| 83. |
How we can use Glyphicons in Bootstrap? |
|
Answer» Bootstrap has around 260 glyphicons, which can be used on any website. For Bootstrap, these ICON fonts are available for free. Let us now see how we can use Glyphicons on our website: Under the Bootstrap folder, which you MAY have downloaded to work with Bootstrap, a “fonts” folder can be SEEN. The same folder has all the icons. Every Glyphicon has a name, which you need to use as shown below: <span class = "glyphicon glyphicon-name"></span>Set the name of the glyphicon under “gplyphicon-name”: <span class = "glyphicon glyphicon-user"></span>You can set the icon in a button as well as shown below: <button type = "button" class = "btn btn-primary btn-sm"> <span class = "glyphicon glyphicon-user"></span> User </button>Here is an example that shows how to add icons: <!DOCTYPE html> <html lang="en"> <head> <title>Bootstrap Example</title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script> </head> <body> <div class="container mt-3"> <h2>Glyphicons</h2> <p>Working with Glyphicons in Bootstrap:</p> <button type = "button" class = "btn btn-primary btn-sm"> <span class = "glyphicon glyphicon-user"></span> User </button> <button type = "button" class = "btn btn-primary btn-lg"> <span class = "glyphicon glyphicon-search"></span> Search </button> </div> </body> </html>The output displays the icons in a button: |
|
| 84. |
Create Inline form in Bootstrap |
|
Answer» Inline forms are the forms in which the elements are inline and left-aligned. To CREATE an inline form, include Bootstrap class .form-inline to the <form> tag. Let us see an example: Note: Resize the web browser to see the effect <!DOCTYPE html> <html lang="EN"> <head> <title>Bootstrap Example</title> <META charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script> </head> <body> <div class="container"> <h2>Inline Form in Bootstrap</h2> <form class="form-inline" action=""> <div class="form-group"> <label for="email">Email address:</label> <input type="email" class="form-control" id="email"> </div> <div class="form-group"> <label for="PWD">Password:</label> <input type="password" class="form-control" id="pwd"> </div> <button type="submit" class="btn btn-default">Submit</button> </form> </div> </body> </html>Here is the output when the screen size is below 767 px: Here is the output when the screen size is above 767 px. All the elements are now inline and left-aligned |
|
| 85. |
What is a Bootstrap Well? |
|
Answer» Bootstrap WELL is a container that adds a rounded border around an element. It adds padding and gray background color. Let us now learn how to create a Bootstrap Well: <div class = "well"> This is my well! </div>We will now implement the above in a web page: <!DOCTYPE html> <html LANG="en"> <head> <title>Bootstrap Example</title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script> </head> <body> <div class="container"> <h2>Learning about WELLS in Bootstrap</h2> <div class = "well"> This is my well! </div> </div> </body> </html>Above creates the following well: The SIZE of Well can also be changed in Bootstrap using well-sm and well-lg classes. Here, we are implementing them: <!DOCTYPE html> <html lang="en"> <head> <title>Bootstrap Well Example</title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script> </head> <body> <div class="container"> <h2>Learning about Wells in Bootstrap</h2> <div class = "well well-sm"> This is my well! Smaller! </div> <div class = "well"> This is my well! Medium! </div> <div class = "well well-lg"> This is my well! LARGE! </div> </div> </body> </html>Here is the output: |
|
| 86. |
Define Bootstrap Panels |
|
Answer» The Bootstrap Panel COMPONENT allow you to add a bordered container with some padding AROUND the CONTENT inside it. The .panel CLASS is used in Bootstrap to create a panel. However, you need to include another class for content i.e. panel-body. Let us see an example to create a panel: <!DOCTYPE html> <html lang="en"> <head> <title>Bootstrap Example</title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script> </head> <body> <div class="container"> <h2>Panels in Bootstrap</h2> <div class="panel panel-default"> <div class="panel-body">This is our Panel</div> </div> </div> </body> </html>The following output DISPLAYS Panels in Bootstrap: You can also add a separate heading to a panel using the .panel-heading class. Let us see an example of headings in Panel: <!DOCTYPE html> <html lang="en"> <head> <title>Bootstrap Example</title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script> </head> <body> <div class="container"> <h2>Panels in Bootstrap</h2> <div class="panel panel-default"> <div class="panel-heading">Panel Heading</div> <div class="panel-body">This is our Panel</div> </div> </div> </body> </html>The following is the output: |
|
| 87. |
Column Ordering in Bootstrap? |
|
Answer» With Bootstrap, you can easily order columns with PUSH and pull i.e. change the order of built-in grid columns. Use the .col-md-push-* and .col-md-pull-* classes to change the order of columns. Here, * range from 1 to 12. Let us SEE an example wherein we have ordered columns: <!DOCTYPE html> <html lang="en"> <head> <title>Bootstrap Example</title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" HREF="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script> </head> <body> <div class="container-fluid"> <h1>Column Ordering</h1> <p><strong>Note: </strong>Resize the web BROWSER to see the effect.</p> <h2>Before ordering columns</h2> <div class="row"> <div class="col-sm-4" style="background-color:blue;color: white;">Demo</div> <div class="col-sm-8" style="background-color:orange;color: white;">Demo</div> </div> <h2>After ordering columns</h2> <div class="row"> <div class="col-sm-4 col-sm-push-8" style="background-color:blue;color: white;">Demo</div> <div class="col-sm-8 col-sm-pull-4" style="background-color:orange;color: white;">Demo</div> </div> </div> </body> </html>In the above web page, we have SHOWN what happens when we order columns using the push and pull classes. |
|
| 88. |
Why Offset Columns introduced in Bootstrap |
|
Answer» Move columns for more spacing to the right with offset columns in Bootstrap. For offsets on large displays, you need to use the .offset-md-* class. Through this, you can INCREASE the left margin of a column by * columns. The value of * here is from 1 to 11. Let us see an EXAMPLE: <!DOCTYPE html> <html lang="en"> <head> <TITLE>Bootstrap Example</title> <meta charset="utf-8"> <meta NAME="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script> </head> <body> <div class="container-fluid"> <h1>Offset Columns</h1> <p><strong>Note: </strong>Resize the web browser to see the effect.</p> <div class="row" style="background-color:yellow;"> <div class="col-sm-5 col-md-6" style="background-color:green;color: white;">Demo</div> <div class="col-sm-5 col-sm-offset-2 col-md-6 col-md-offset-0" style="background-color:blue;color: white;">Demo</div> </div> </div> </body> </html>The FOLLOWING is the output, wherein you can see the left margin since we have set offset in the second column: |
|
| 89. |
Grid Structure in Bootstrap |
|
Answer» Bootstrap has a responsive, mobile first fluid GRID system that APPROPRIATELY scales up to 12 columns as the device or viewport size increases. This states that firstly Bootstrap targets mobile devices and then EXPANDS to other devices such as tablet and desktop. The grid structure in Bootstrap looks like this: <div class = "CONTAINER"> <div class = "row"> <div class = "col-*-*"></div> <div class = "col-*-*"></div> </div> <div class = "row"> <div class = "col-*-*"></div> <div class = "col-*-*"></div> </div> </div>Let us now understand what we did above: We used the following to create a row: <div class = "row"> … </div>To add columns: col-*-*The first * above is for screen responsiveness class i.e.: col-sm: small devices col-md: medium size devices col-lg: large devices col-xl: extra large devicesThe second * sets a number that adds up to 12 for a row, for example, a row with 4 equal columns: <div class="row"> <div class="col-sm-3" STYLE="background-color:green;color:white;">.col-sm-3</div> <div class="col-sm-3" style="background-color:orange;color:gray">.col-sm-3</div> <div class="col-sm-3" style="background-color:violet;color:white">.col-sm-3</div> <div class="col-sm-3" style="background-color:black;color:white">.col-sm-3</div> </div> |
|
| 90. |
Can Tabs be centered in Bootstrap? |
|
Answer» Yes, with Bootstrap, you can easily center tabs. The .nav-justified class is used in Bootstrap to center tabs. The following is an example: <!DOCTYPE html> <html lang="en"> <head> <title>Bootstrap Tabs</title> <meta charset="utf-8"> <meta name="VIEWPORT" content="width=device-width, initial-scale=1"> <link rel="stylesheet" HREF="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script> </head> <body> <div class="CONTAINER"> <h3>Centered Tabs</h3> <p><strong>Note:</strong> RESIZE the browser window to see the effect. Items look stacked if the screen size if less than 768px</p> <UL class="nav nav-tabs nav-justified"> <li class="active"><a href="#">Home</a></li> <li><a href="#">AboutUs</a></li> <li><a href="#">Company</a></li> </ul> </div> </body> </html>The output when the screen size is less than 768px: The output when the screen size is more than 768px: |
|
| 91. |
Why the align-items-sm-baseline class used in Bootstrap 4? |
|
Answer» The ALIGN-ITEMS-sm-BASELINE class is USED in Bootstrap to align single ROWS of items on the baseline on small screen. |
|
| 92. |
How to display flex items vertically on small screen in Bootstrap 4? |
|
Answer» Display FLEX items vertically using the flex-xx-column class used in BOOTSTRAP. To display flex items vertically on small screen, use the flex-sm-column class: <DIV class="d-flex flex-sm-column"> |
|
| 93. |
Why the flex-md-row-reverse class used in Bootstrap 4? |
|
Answer» Display FLEX items horizontally and right-align on MEDIUM screen USING the flex-md-row-reverse CLASS in Bootstrap. |
|
| 94. |
Why Bootstrap has a Grid System? |
||||||||||||||||||
|
Answer» Bootstrap has a responsive, mobile first fluid grid system that APPROPRIATELY SCALES up to 12 columns as the DEVICE or viewport size increases. This states that FIRSTLY Bootstrap targets mobile devices and then expands to other devices such as tablet and desktop. The Bootstrap Grid System displays 12 columns in a PAGE. These columns will rearrange on its own, since the Grid system is responsive. Bootstrap provides the following classes:
Let us now understand this using an example. For four equal columns, use four .col-sm-3 classes like this: <!DOCTYPE html> <html lang="en"> <head> <title>Bootstrap Demo</title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"></script> </head> <body> <div class="container-fluid"> <h2>Grid System in Bootstrap</h2> <p><strong>Note:</strong> Resize the browser window to see the effect. The columns stack on top of each other when the screen is < 576px.</p> <div class="row"> <div class="col-sm-3" style="background-color:green;color:white;">.col-sm-3</div> <div class="col-sm-3" style="background-color:orange;color:gray">.col-sm-3</div> <div class="col-sm-3" style="background-color:violet;color:white">.col-sm-3</div> <div class="col-sm-3" style="background-color:black;color:white">.col-sm-3</div> </div> </div> </body> </html>The output when screen size is more than 576px: The output when screen size is less than 576px. As you can see the columns stack on top of each other: |
|||||||||||||||||||
| 95. |
Why the .flex-sm-shrink-1 class used in Bootstrap 4? |
|
Answer» Make flex-items SHRINK on small screen using the flex-sm-shrink-1 class USED in BOOTSTRAP. |
|
| 96. |
Bootstrap Collapse example? |
|
Answer» The Bootstrap collapse is used to show and hide content. The following are used for Collapsible: .collapse: hides content .collapse.show: to show contentBootstrap collapse with .collapse class Let us see an example of Bootstrap collapse with .collapse class. It shows the content hidden by default: <!DOCTYPE html> <html lang="en"> <head> <title>Bootstrap Demo</title> <meta charset="utf-8"> <meta NAME="viewport" content="width=device-width, initial-scale=1"> <link REL="STYLESHEET" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"></script> </head> <body> <div class="CONTAINER"> <h2>Bootstrap Collapsible</h2> <p>Show or hide the content:</p> <button type="button" class="btn btn-info" data-toggle="collapse" data-target="#mydiv">Click me</button> <div id="mydiv" class="collapse"> This is the content which is toggled on button click. </div> </div> </body> </html>The following is the output that shows toggled content (show or hide) on button click. FIRST, let us see the result on running: After that, click the above button that toggles content. On clicking, the collapsed content will be visible: Bootstrap collapse with .collapse show Let us see an example of .collapse with .show class. It hides the content by default: <!DOCTYPE html> <html lang="en"> <head> <title>Bootstrap Demo</title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"></script> </head> <body> <div class="container"> <h2>Bootstrap Collapsible</h2> <p>Show or hide the content:</p> <button type="button" class="btn btn-info" data-toggle="collapse" data-target="#mydiv">Click me</button> <div id="mydiv" class="collapse show"> This is the content which is toggled on button click. </div> </div> </body> </html>The following is the output that displays the content by default since we used the show class as well: |
|
| 97. |
What is a Bootstrap Container? |
|
Answer» Bootstrap needed something to wrap elements and CONTAIN its grid system, therefore that leaded to introduction of container, which can be fixed or fluid. Fixed Container Use the container class when you want fixed-WIDTH which is responsive. Include it like this: <div class="container"> … </div>The following is an example: <!DOCTYPE html> <html LANG="en"> <head> <title>Bootstrap Demo</title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"></script> </head> <body> <div class="container"> <h1>Demo Page</h1> <p>The .container class provides a fixed width container.</p> </div> </body> </html>Fluid Container Use the container-fluid element to provide a full width container that spans the entire width of the viewport: Include it like this: <div class="container-fluid"> … </div>Let us SEE an example: <!DOCTYPE html> <html lang="en"> <head> <title>Bootstrap Demo</title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"></script> </head> <body> <div class="container-fluid"> <h1>Demo Page</h1> <p>The .container-fluid class provides a full width container that spans the entire width of the viewport.</p> </div> </body> </html> |
|
| 98. |
How to make a link unclickable in Bootstrap Navbar? |
|
Answer» In a NavBar, if you want to make a link unclickable, then use the .disabled class. Let’s say we have a Navbar with some items and out of which you want to disable the “Entertainment” link and make unclickable. For that, use the .disabled class LIKE this: <li class="nav-item"> <a class="nav-link disabled" href="#">Tech</a> </li>Now, let us see how we can create more items in Navbar and disable one of them. For the second Navbar, we have made the link “Tech” unclickable: <!DOCTYPE html> <html lang="en"> <head> <title>Bootstrap Navbar</title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css"> <script SRC="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"></script> </head> <body> <DIV class="CONTAINER"> <h3>Disable Navbar</h3> </div> <nav class="navbar navbar-expand-sm bg-danger navbar-light"> <ul class="navbar-nav"> <li class="nav-item"> <a class="nav-link" href="#">HOME</a> </li> <li class="nav-item"> <a class="nav-link disabled" href="#">About</a> </li> <li class="nav-item"> <a class="nav-link" href="#">Entertainment</a> </li> <li class="nav-item"> <a class="nav-link disabled" href="#">Tech</a> </li> </ul> </nav> <nav class="navbar navbar-expand-sm bg-primary navbar-light"> <ul class="navbar-nav"> <li class="nav-item"> <a class="nav-link" href="#">Home</a> </li> <li class="nav-item"> <a class="nav-link" href="#">About</a> </li> <li class="nav-item"> <a class="nav-link disabled" href="#">Entertainment</a> </li> <li class="nav-item"> <a class="nav-link" href="#">Tech</a> </li> </ul> </nav> </body> </html>The output: |
|
| 99. |
How to wrap flex items on different screens in Bootstrap? |
|
Answer» <P>To wrap items on different screens in Bootstrap, use the flex-wrap class. Let us see how to use this class for different screens:
Use flex-sm-wrap for small screen: <DIV class="d-flex flex-sm-wrap bg-primary">
Use flex-md-wrap for medium screen: <div class="d-flex flex-md-wrap bg-primary">
Use flex-lg-wrap for large screen: <div class="d-flex flex-lg-wrap bg-primary">
Use flex-xl-wrap for extra large screen: <div class="d-flex flex-xl-wrap bg-primary">The following is an example that wraps flex items on different screen size: <!DOCTYPE html> <html lang="EN"> <head> <title>Bootstrap Flex Wrap Example</title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <LINK rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"></script> </head> <body> <div class="container mt-3"> <h3>Books</h3> <div class="d-flex flex-wrap bg-primary"> <div class="p-2 border">Book1</div> <div class="p-2 border">Book2</div> <div class="p-2 border">Book3</div> <div class="p-2 border">Book4</div> <div class="p-2 border">Book5</div> <div class="p-2 border">Book6</div> <div class="p-2 border">Book7</div> <div class="p-2 border">Book8</div> <div class="p-2 border">Book9</div> <div class="p-2 border">Book10</div> </div> <br> <p>Wraps on Small Screen (>576px)</p> <div class="d-flex flex-sm-wrap bg-primary"> <div class="p-2 border">Book1</div> <div class="p-2 border">Book2</div> <div class="p-2 border">Book3</div> <div class="p-2 border">Book4</div> <div class="p-2 border">Book5</div> <div class="p-2 border">Book6</div> <div class="p-2 border">Book7</div> <div class="p-2 border">Book8</div> <div class="p-2 border">Book9</div> <div class="p-2 border">Book10</div> </div><br> <p>Wraps on Medium sized screen (>768px)</p> <div class="d-flex flex-md-wrap bg-primary"> <div class="p-2 border">Book1</div> <div class="p-2 border">Book2</div> <div class="p-2 border">Book3</div> <div class="p-2 border">Book4</div> <div class="p-2 border">Book5</div> <div class="p-2 border">Book6</div> <div class="p-2 border">Book7</div> <div class="p-2 border">Book8</div> <div class="p-2 border">Book9</div> <div class="p-2 border">Book10</div> </div><br> <p>Wraps on Large Screen (>992px)</p> <div class="d-flex flex-lg-wrap bg-primary"> <div class="p-2 border">Book1</div> <div class="p-2 border">Book2</div> <div class="p-2 border">Book3</div> <div class="p-2 border">Book4</div> <div class="p-2 border">Book5</div> <div class="p-2 border">Book6</div> <div class="p-2 border">Book7</div> <div class="p-2 border">Book8</div> <div class="p-2 border">Book9</div> <div class="p-2 border">Book10</div> <div class="p-2 border">Book11</div> <div class="p-2 border">Book12</div> <div class="p-2 border">Book13</div> </div><br> <p>Wraps on Extra Large Screen (>1200px)</p> <div class="d-flex flex-xl-wrap bg-primary"> <div class="p-2 border">Book1</div> <div class="p-2 border">Book2</div> <div class="p-2 border">Book3</div> <div class="p-2 border">Book4</div> <div class="p-2 border">Book5</div> <div class="p-2 border">Book6</div> <div class="p-2 border">Book7</div> <div class="p-2 border">Book8</div> <div class="p-2 border">Book9</div> <div class="p-2 border">Book10</div> <div class="p-2 border">Book11</div> <div class="p-2 border">Book12</div> <div class="p-2 border">Book13</div> <div class="p-2 border">Book14</div> <div class="p-2 border">Book15</div> <div class="p-2 border">Book16</div> <div class="p-2 border">Book17</div> <div class="p-2 border">Book18</div> <div class="p-2 border">Book19</div> </div><br> </div> </body> </html>The output for screen size above 576px. The flex-sm-wrap wraps on small screen size: The output for screen size above 768px. The flex-md-wrap wraps on medium screen size: The output for screen size above 1200px. The flex-xl-wrap wraps on extra-large screen size: |
|
| 100. |
How to add inline subheadings in Bootstrap |
|
Answer» The <small> ELEMENT is used if you want to add inline subheadings to headings. You can also use the .small class and get a text SMALLER than the normal text To add an inline subheading to any of the headings, simply add <small> around any of the elements or add .small class and you will get smaller text in a lighter color. The below example creates inline subheading under <h1> and <h2>: <!DOCTYPE html> <html lang="en"> <head> <TITLE>Bootstrap Inline Subheading</title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link REL="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script> </head> <body> <div class="container"> <h1>Heading1 <small> Smaller Heading1 </small> </h1> <h2>Heading2 <small> Smaller Heading2 </small> </h2> </div> </body> </html>The above displays the following OUTPUT with inline subheadings: |
|