InterviewSolution
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.
| 1. |
Fix the navbar to the top in Bootstrap |
|
Answer» Fixed Navigation BAR in BOOTSTRAP allow you to fix the navbar at the top. USE the .navbar-fixed-top class to achieve the same: <nav class="navbar navbar-default navbar-fixed-top">To check with a scrollbar, we have styled the body height as 1200px: <body style="height:1200px">Now, when you will scroll the page, the navigation bar would remain fixed on the top. You may have seen the same on a lot of websites these days. The output displays the navigation bar fixed at top. Notice the scrollbar on the right. The changes in the scrollbar won’t affect the position of the navigation bar at the top: |
|
| 2. |
How to align the dropdown menu to right in Bootstrap? |
|
Answer» To align the menus on your website, you can use the .dropdown-menu-right class. It aligns the dropdown menus on the right. 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> |
|
| 3. |
What is "multiple" in <select> in Bootstrap |
|
Answer» For selecting a single option from a set of multiple options, we use select. However, with select as multiple (select multiple), we can select more than one option. The below output is visible with select options: Now, press “CTRL” key and select multiple options. On selection the options, it gets highlighted as shown below: |
|
| 4. |
Lead Body Copy in Bootstrap |
|
Answer» Add emphasis to a paragraph with BOOTSTRAP lead class. It is Typography class in Bootstrap. Let us SEE an example to understand the difference between lead body copy and a regular demo paragraph: <!DOCTYPE HTML> <html LANG="en"> <head> <title>Bootstrap Lead Body Copy</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>Lead Body Copy</h2> <p class = "lead">This is demo paragraph. This is demo paragraph. This is demo paragraph. This is demo paragraph. This is demo paragraph. This is demo paragraph. This is demo paragraph. </p> <p>This is a demo paragraph.</p> </div> </body> </html>The output displays how to use the lead class in Bootstrap to stand out paragraph: |
|
| 5. |
Set Block level help text in Bootstrap |
|
Answer» In Bootstrap forms, you can add a block level help text USING help-block class. The output: |
|
| 6. |
Why breadcrumb is used in Bootstrap? |
|
Answer» Breadcrumbs display hierarchy-based information and the current page location. On a website, breadcrumbs display categories, and tags and help users in navigation and letting them know where they have reached. Let us now SEE an EXAMPLE in Bootstrap to ADD Breadcrumbs: <!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> <nav aria-label="breadcrumb"> <ol class="breadcrumb"> <li class="breadcrumb-item"><a href="#">Home</a></li> <li class="breadcrumb-item"><a href="#">Tutorials</a></li> <li class="breadcrumb-item active" aria-current="page">Java</li> </ol> </nav> </body> </html>The above code displays the following breadcrumb navigation: |
|
| 7. |
Add auto margins to flex items in Bootstrap |
|
Answer» The two classes you need to use for adding auto margins to flex items are .mr-auto and .ml-auto. The OUTPUT shifts items to the right: Let us first see .ml-auto that place items to the left: <!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>Flex Items</h2> <div class="d-flex mb-3 bg-warning"> <div class="p-2 bg-primary">Item 1</div> <div class="p-2 bg-info">Item 2</div> <div class="p-2 ml-auto bg-danger">Item 3</div> </div> </div> </body> </html>The output shifts items to the left: |
|
| 8. |
Is a Bootstrap Well a container? |
|
Answer» Yes, a BOOTSTRAP Well is a container. It is a container in <div> through which the content appears sunken. As you can see below a basic container is 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: |
|
| 9. |
How can we make the checkboxes to appear on the same line in Bootstrap? |
|
Answer» The .form-check-inline class is used in Bootstrap to MAKE the checkboxes to appear on the same line. This form of checkboxes is known as Inline Checkboxes. The output: |
|
| 10. |
Nest button groups within another button group in Bootstrap |
|
Answer» To nest button groups within another button group, you need to include one button group into another. The following is an example that displays nested Button Groups. Here, we have three buttons in a Button group. The second button has a nested Button Groups that displays the YEAR in which India won WORLD Cup. The example: <!DOCTYPE html> <html lang="en"> <head> <title>Nest Bootstrap Button Groups</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>WorldCup</h2> <p>The following is the information about the ODI World Cup winning teams:</p> <div class="btn-group"> <button TYPE="button" class="btn btn-primary">West INDIES</button> <div class = "btn-group"> <button type = "button" class = "btn btn-primary dropdown-toggle" data-toggle = "dropdown"> India <span class = "CARET"></span> </button> <ul class = "dropdown-menu"> <li><a href = "#">1983</a></li> <li><a href = "#">2011</a></li> </ul> </div> <button type="button" class="btn btn-primary">New Zealand</button> </div> </div> </body> </html>Here is the output that displays nested Button Groups. The second button in the button group is nested as shown below: |
|
| 11. |
Center the Bootstrap modal vertically and horizontally within the page |
|
Answer» Use the .modal-dialog-centered class to center the Bootstrap modal vertically and horizontally within the page. <div class="modal-dialog modal-dialog-centered">Generally, by DEFAULT, a modal appears like this. You can see it is not vertically and horizontally centered: But, the modal after using the .modal-dialog-centered class will look vertically and horizontally centered: Let us now see an example: <!DOCTYPE html> <html lang="en"> <head> <TITLE>Bootstrap Modal</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>Modal in Bootstrap</h2> <p>Fading effect in Modal...</p> <button type="button" class="btn btn-primary" data-toggle="modal" data-target="#newModal"> Open </button> <div class="modal fade" id="newModal"> <div class="modal-dialog modal-dialog-centered"> <div class="modal-content"> <div class="modal-header"> <h4 class="modal-title">Modal Heading</h4> <button type="button" class="close" data-dismiss="modal">×</button> </div> <div class="modal-body"> Body of the modal... </div> <div class="modal-footer"> <button type="button" class="btn btn-danger" data-dismiss="modal">Close</button> </div> </div> </div> </div> </div> </body> </html>The above centers the Bootstrap modal vertically and horizontally within the page: |
|
| 12. |
Add a fading effect when opening and closing the Bootstrap modal |
|
Answer» To add fading effect for a BOOTSTRAP Modal, use the .fade class. Add this class in the modal container <div class="modal fade" id="newModal">Let US see an example of Bootstrap modal fading effect: <!DOCTYPE html> <html lang="en"> <head> <TITLE>Bootstrap Modal</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>Modal in Bootstrap</h2> <p>Fading effect in Modal...</p> <button type="button" class="btn btn-primary" data-toggle="modal" data-target="#newModal"> Open </button> <div class="modal fade" id="newModal"> <div class="modal-dialog"> <div class="modal-content"> <div class="modal-header"> <h4 class="modal-title">Modal Heading</h4> <button type="button" class="close" data-dismiss="modal">×</button> </div> <div class="modal-body"> Body of the modal... </div> <div class="modal-footer"> <button type="button" class="btn btn-danger" data-dismiss="modal">Close</button> </div> </div> </div> </div> </div> </body> </html>The output looks like this: On clicking the “Open” button, the modal opens and the fading effect is visible. The same fading effect can be seen on closing the modal: |
|
| 13. |
Can we disallow flex-items wrap on large screen in Bootstrap 4? |
|
Answer» Use the flex-lg-nowrap class in Bootstrap 4 to not allow flex-item to WRAP on large screen. Use it LIKE this: <DIV class="d-flex flex-lg-nowrap bg-light"> Flex ITEMS . . . </div> |
|
| 14. |
Fix the navbar to the bottom in Bootstrap |
|
Answer» Fixed Navigation Bar in Bootstrap allow you to fix the navbar at the bottom. Use the .navbar-fixed-bottom class to ACHIEVE the same: <nav class="navbar navbar-default navbar-fixed-bottom">To CHECK with a scrollbar, we have styled the body height as 1200px: <body style="height:1200px">Now, when you will scroll the page, the navigation bar would remain fixed on the bottom. The following example fix the navbar to the bottom: <!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 style="height:1200px"> <nav class="navbar navbar-default navbar-fixed-bottom"> <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 displays the navigation bar fixed at bottom. Notice the scrollbar on the right. The changes in the scrollbar won’t AFFECT the position of the navigation bar at the bottom: |
|
| 15. |
How to create colored Navbar in Bootstrap? |
|
Answer» To create a colored Navbar, firstly work around the same procedure to create a Navbar. Then, use the .bg-color classes to change the background color. These classes include: .bg-primary, .bg-success, .bg-info, .bg-warning, .bg-danger, .bg-secondary, .bg-dark and .bg-light classes. The OUTPUT displays a colored Navbar: Now, let us add more navbars with different colors using the classes discussed above: <!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"> <h3>Colored Navbars</h3> </div> <nav class="navbar navbar-expand-sm bg-primary navbar-dark"> <ul class="navbar-nav"> <li class="nav-item active"> <a class="nav-link" href="#" active>Home</a> </li> <li class="nav-item"> <a class="nav-link" href="#">About</a> </li> <li class="nav-item"> <a class="nav-link" href="#">Entertainment</a> </li> <li class="nav-item"> <a class="nav-link" href="#">News</a> </li> <li class="nav-item"> <a class="nav-link" href="#">Contact</a> </li> </ul> </nav> <nav class="navbar navbar-expand-sm bg-secondary navbar-dark"> <ul class="navbar-nav"> <li class="nav-item active"> <a class="nav-link" href="#" active>Home</a> </li> <li class="nav-item"> <a class="nav-link" href="#">About</a> </li> <li class="nav-item"> <a class="nav-link" href="#">Entertainment</a> </li> <li class="nav-item"> <a class="nav-link" href="#">News</a> </li> <li class="nav-item"> <a class="nav-link" href="#">Contact</a> </li> </ul> </nav> <nav class="navbar navbar-expand-sm bg-danger navbar-dark"> <ul class="navbar-nav"> <li class="nav-item active"> <a class="nav-link" href="#" active>Home</a> </li> <li class="nav-item"> <a class="nav-link" href="#">About</a> </li> <li class="nav-item"> <a class="nav-link" href="#">Entertainment</a> </li> <li class="nav-item"> <a class="nav-link" href="#">News</a> </li> <li class="nav-item"> <a class="nav-link" href="#">Contact</a> </li> </ul> </nav> <nav class="navbar navbar-expand-sm bg-warning navbar-dark"> <ul class="navbar-nav"> <li class="nav-item active"> <a class="nav-link" href="#" active>Home</a> </li> <li class="nav-item"> <a class="nav-link" href="#">About</a> </li> <li class="nav-item"> <a class="nav-link" href="#">Entertainment</a> </li> <li class="nav-item"> <a class="nav-link" href="#">News</a> </li> <li class="nav-item"> <a class="nav-link" href="#">Contact</a> </li> </ul> </nav> </body> </html>The output with Navbars in different colors: |
|
| 16. |
How to highlight the current link in Bootstrap Navbar? |
|
Answer» In a NavBar, if you want to highlight the current link, then use the .active class. Now, let us see how we can create more items in Navbar and highlight one of them. For the SECOND Navbar, we have HIGHLIGHTED the item “Tech”: <!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>Highlight Navbar</h3> </div> <nav class="navbar navbar-expand-sm bg-danger navbar-dark"> <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 active"> <a class="nav-link" href="#">Entertainment</a> </li> <li class="nav-item"> <a class="nav-link" href="#">Tech</a> </li> </ul> </nav> <nav class="navbar navbar-expand-sm bg-primary navbar-dark"> <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" href="#">Entertainment</a> </li> <li class="nav-item active"> <a class="nav-link" href="#">Tech</a> </li> </ul> </nav> </body> </html>The OUTPUT: |
|
| 17. |
Can we create an Inverted Navbar in Bootstrap? |
|
Answer» With Bootstrap, you can change the theme of the default navigation bar. Yes, you can create an inverted NAVBAR using the .navbar-inverse CLASS. We create a default navbar using navbar-default class: <nav class="navbar navbar-default” role = "navigation">Above will create a default navbar with the following STYLE: Replace the .navbar-default class with the class to create inverted Navbar: <nav class="navbar navbar-inverse” role = "navigation">The following is an example that displays how we can crate inverted Navbar (black COLORED): <!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-inverse" 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 above code creates the following inverted navbar unlike the default navbar: |
|
| 18. |
Can we remove borders from a table in Bootstrap? |
|
Answer» The table without a border is known as borderless border. Bootstrap provides a separate class to create a borderless table. This class removes borders from a table. The output displays both bordered as well as borderless table: |
|
| 19. |
Add a hover effect on table rows in Bootstrap |
|
Answer» The .table-hover class is used in BOOTSTRAP to add a hover effect on table rows. A GREY background color is VISIBLE when mouse hovers. The output displays the following table: On mouse hover over any of the row, a gray background color is visible: |
|
| 20. |
How to display flex items in between the flex container on medium size screen in Bootstrap 4? |
|
Answer» Display flex items in between on medium SCREEN USING the justify-content-md-between class in Bootstrap. The following output displays the flex items are visible in between the flex container on medium screen size: |
|
| 21. |
Why the justify-content-xl-center class used in Bootstrap 4? |
|
Answer» Display flex items in the center of a flex container on extra-large screen using the justify-content-XL-center class USED in Bootstrap. We have used xl for extra-large screen SIZE: <div class="d-flex justify-content-xl-center bg-primary"> Flex items . . . </div>Above, bg-primary is a contextual class to set background color. |
|
| 22. |
How to change the size of Bootstrap well? |
|
Answer» Bootstrap Well is a container that adds a rounded border around an element. It adds padding and gray background color. The size of Well can 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>Size of 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:We can also create a Bootstrap Well with the default size: <div class = "well"> This is my well! </divThe FOLLOWING is an example WHEREIN we have created a Bootstrap Well with the default size: <!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”: |
|
| 23. |
What should be done in Bootstrap to hide and show large amount of content |
|
Answer» The collapsibles are used in Bootstrap to hide and shows large amount of content. The following are used for Collapsible: .collapse: HIDES content .collapse.show: to show contentLet us see an example of Bootstrap collapse with .collapse class: <!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: |
|
| 24. |
Which class is used to create a grid of cards that are of equal height and width? |
|
Answer» The .card-deck is USED in Bootstrap to CREATE a grid of cards of EQUAL height and width. Let us first see how we can set TWO cards inside the .card-deck class: <!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>Grid of Cards</h2> <div class="card-deck"> <div class="card bg-secondary"> <div class="card-body text-center"> <p class="card-text">This is example text1.</p> <p class="card-text">This is example text2.</p> <p class="card-text">This is example text3.</p> <p class="card-text">This is example text4.</p> </div> </div> <div class="card bg-info"> <div class="card-body text-center"> <p class="card-text">This is example text1.</p> <p class="card-text">This is example text2.</p> </div> </div> </div> </div> </body> </html>The above sets two cards of equal height and width: Let us now add more cards to the grid of cards. This will show how the card align themselves: <!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>Grid of Cards</h2> <div class="card-deck"> <div class="card bg-secondary"> <div class="card-body text-center"> <p class="card-text">This is example text1.</p> <p class="card-text">This is example text2.</p> <p class="card-text">This is example text3.</p> <p class="card-text">This is example text4.</p> </div> </div> <div class="card bg-info"> <div class="card-body text-center"> <p class="card-text">This is example text1.</p> <p class="card-text">This is example text2.</p> <p class="card-text">This is example text2.</p> </div> </div> <div class="card bg-warning"> <div class="card-body text-center"> <p class="card-text">This is example text1.</p> <p class="card-text">This is example text2.</p> <p class="card-text">This is example text3.</p> <p class="card-text">This is example text4.</p> </div> </div> <div class="card bg-danger"> <div class="card-body text-center"> <p class="card-text">This is example text1.</p> <p class="card-text">This is example text2.</p> <p class="card-text">This is example text2.</p> </div> </div> </div> </div> </body> </html>The output displays 4 cards in the deck of cards: |
|
| 25. |
Add background color to the Bootstrap Card |
|
Answer» The contextual classes are used in Bootstrap to ADD background color to a card. The following are the contextual classes that can be used: .bg-primary, .bg-success, .bg-info, .bg-warning, .bg-danger, .bg-secondary, .bg-dark and .bg-light. The following is an example that adds background color to a Bootstrap card: <!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>Cards with different background colors</h2> <div class="card"> <div class="card-body">Default</div> </div> <br> <div class="card bg-primary text-white"> <div class="card-body">Primary</div> </div> <br> <div class="card bg-secondary text-white"> <div class="card-body">Secondary</div> </div> <br> <div class="card bg-success text-white"> <div class="card-body">Success</div> </div> <br> <div class="card bg-info text-white"> <div class="card-body">Info</div> </div> <br> <div class="card bg-warning text-white"> <div class="card-body">Warning</div> </div> <br> <div class="card bg-danger text-white"> <div class="card-body">Danger</div> </div> <br> <div class="card bg-dark text-white"> <div class="card-body">Dark</div> </div> <br> </div> </body> </html>The output displays cards with different background colors: |
|
| 26. |
How to build a dismissal alert in Bootstrap? |
|
Answer» To create alert messages on your website, work with the Alert component in Bootstrap. We will use the .alert class for this purpose. The dismissal alert provided user with an option to close the alert message. For this purpose, use the .alert-dismissible class. After that include class="close" and data-dismiss="alert". Here, we will use × HTML character to display the close sign for closing alert buttons. 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"> <h2>Dismissible Alerts</h2> <div class="alert alert-success alert-dismissible"> <button type="button" class="close" data-dismiss="alert">×</button> <strong>Success! You cracked it!</strong> </div> <div class="alert alert-info alert-dismissible"> <button type="button" class="close" data-dismiss="alert">×</button> <strong>Information! More Info!</strong> </div> <div class="alert alert-warning alert-dismissible"> <button type="button" class="close" data-dismiss="alert">×</button> <strong>Warning! Close program to prevent system failure!</strong> </div> <div class="alert alert-DANGER alert-dismissible"> <button type="button" class="close" data-dismiss="alert">×</button> <strong>Danger! MALWARE ahead!</strong> </div> <div class="alert alert-primary alert-dismissible"> <button type="button" class="close" data-dismiss="alert">×</button> <strong>Primary!</strong> </div> <div class="alert alert-secondary alert-dismissible"> <button type="button" class="close" data-dismiss="alert">×</button> <strong>Secondary!</strong> </div> <div class="alert alert-dark alert-dismissible"> <button type="button" class="close" data-dismiss="alert">×</button> <strong>Dark alert!</strong> </div> </div> </body> </html>The output displays dismissible alerts: |
|
| 27. |
How to include list groups within any panel in Bootstrap? |
|
Answer» To include list groups within any panel, try the following steps:
Let us now see how we can create list groups within 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-heading">Panel Heading</div> <div class="panel-body">This is our Panel</div> <ul class = "list-group"> <li class = "list-group-item">One</li> <li class = "list-group-item">Two</li> <li class = "list-group-item">Three</li> <li class = "list-group-item">Four</li> <li class = "list-group-item">Five</li> <li class = "list-group-item">Six</li> <li class = "list-group-item">Seven</li> <li class = "list-group-item">EIGHT</li> </ul> <div class="panel-footer">Panel Footer</div> </div> </div> </body> </html>The OUTPUT displays a panel and 8 group items in a List Group: |
|
| 28. |
Make a set of buttons appear vertically stacked rather than horizontally in Bootstrap |
|
Answer» The .btn-group-vertical class is used in Bootstrap to form a set of BUTTONS appear vertically stacked. This is a class for Button Groups. The following is an example: <!DOCTYPE html> <html lang="en"> <head> <title>Bootstrap Button Groups</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>Teams (Vertical Button Group)</h2> <p>The following is the INFORMATION about the teams:</p> <div class="btn-group-vertical"> <button type="button" class="btn btn-primary">Real Madrid</button> <button type="button" class="btn btn-primary">CSKA Moscow</button> <button type="button" class="btn btn-primary">Manchester United</button> <button type="button" class="btn btn-primary">Barcelona</button> </div> <h2>Teams (Horizontal Button Group)</h2> <p>The following is the information about the teams:</p> <div class="btn-group"> <button type="button" class="btn btn-primary">Real Madrid</button> <button type="button" class="btn btn-primary">CSKA Moscow</button> <button type="button" class="btn btn-primary">Manchester United</button> <button type="button" class="btn btn-primary">Barcelona</button> </div> </div> </body> </html>Here is the output that displays a group of buttons vertically stacked: |
|
| 29. |
Can we align single row of items from the start in Bootstrap? |
|
Answer» Yes, we can align single rows of items from the START USING the align-items-*-start class USED in Bootstrap. Let’s say you need to align from the start on small screen SIZE, for that in place of *, ADD sm for small i.e.: align-items-sm-start |
|
| 30. |
Can a Bootstrap Dropdown menu be built to drop up rather than down? |
|
Answer» <P>A dropdown menu is a standard menu that drop down. But, for your website or web project, if you WANT it to drop up, then it is possible. The following is an EXAMPLE that has drop up menu instead of dropdown. We used the .dropup class in DIV to fulfill our purpose. <!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>Dropup</h2> <p>Example of menu upwards i.e. drop up:</p><br> <div class="dropup"> <button class="btn btn-default dropdown-toggle" type="button" data-toggle="dropdown">Demo <span class="caret"></span></button> <ul class="dropdown-menu"> <li><a href="#">HTML</a></li> <li><a href="#">CSS</a></li> <li><a href="#">JavaScript</a></li> </ul> </div> </div> </body> </html>The output looks like this: Now, clicking on the menu will generate the menu upwards i.e. dropup: |
|
| 31. |
Add Badges to List Groups in Bootstrap |
|
Answer» To add badges to List Groups in Bootstrap, you NEED to add the following in <li class = "list-group-item">: <span class = "BADGE">Let us now add: <ul class = "list-group"> <li class = "list-group-item"><span class = "badge">New</span>ONE</li> <li class = "list-group-item"><span class = "badge">New</span>Two</li> <li class = "list-group-item"><span class = "badge">New</span>Three</li> <li class = "list-group-item"><span class = "badge">New</span>Four</li> <li class = "list-group-item"><span class = "badge">New</span>Five</li> </ul>The following is an EXAMPLE: <!DOCTYPE html> <html> <head> <title>Try v1.2 Bootstrap Online</title> <link href="/bootstrap/css/bootstrap.min.css" rel="stylesheet"> <script src="/scripts/jquery.min.js"></script> <script src="/bootstrap/js/bootstrap.min.js"></script> </head> <body> <DIV class="container"> <h2>Add Badges to List Groups</h2> <ul class = "list-group"> <li class = "list-group-item"><span class = "badge">New</span>One</li> <li class = "list-group-item"><span class = "badge">New</span>Two</li> <li class = "list-group-item"><span class = "badge">New</span>Three</li> <li class = "list-group-item"><span class = "badge">New</span>Four</li> <li class = "list-group-item"><span class = "badge">New</span>Five</li> </ul> </div> </body> </html>The output: |
|
| 32. |
Why the flex-lg-column-reverse class used in Bootstrap 4? |
|
Answer» Display flex ITEMS vertically with reversed order on large screen USING the flex-lg-column-reverse CLASS in BOOTSTRAP. |
|
| 33. |
How to align a flex item in the center on small screen in Bootstrap 4? |
|
Answer» To align a flex item in the CENTER on SMALL SCREEN using the align-self-sm-center class in Bootstrap. This is how you include the class: <div class="p-2 BORDER align-self-sm-center"> Flex item name </div> |
|
| 34. |
Can we stack multiple progress bars in Bootstrap |
|
Answer» With Bootstrap, we can easily stack multiple progress bars. For that, include only a single .progress class and place all the Progress Bars inside it. For example, firstly adding only a single Progress Bar in the .progress class: <DIV class = "progress"> <div class = "progress-bar progress-bar-info" role = "progressbar" aria-valuenow = "20" aria-valuemin = "0" aria-valuemax = "100" style = "width: 20%;"> 20% </div> </div>Now, add another Progress Bar in the same .progress class: <div class = "progress"> <div class = "progress-bar progress-bar-SUCCESS" role = "progressbar" aria-valuenow = "20" aria-valuemin = "0" aria-valuemax = "100" style = "width: 20%;"> 20% </div> <div class = "progress-bar progress-bar-info" role = "progressbar" aria-valuenow = "10" aria-valuemin = "0" aria-valuemax = "100" style = "width: 10%;"> 10% </div> </div>LET us add more Progress Bars in the same .progress class: <!DOCTYPE html> <html lang="en"> <head> <title>Bootstrap Striped Progress Bar</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>Level of monosodium glutamate</h2> <div class = "progress"> <div class = "progress-bar progress-bar-success" role = "progressbar" aria-valuenow = "20" aria-valuemin = "0" aria-valuemax = "100" style = "width: 20%;"> 20% (Success) </div> <div class = "progress-bar progress-bar-info" role = "progressbar" aria-valuenow = "10" aria-valuemin = "0" aria-valuemax = "100" style = "width: 10%;"> 10% (High) </div> <div class = "progress-bar progress-bar-warning" role = "progressbar" aria-valuenow = "35" aria-valuemin = "0" aria-valuemax = "100" style = "width: 35%;"> 35% (Very High - Warning) </div> <div class = "progress-bar progress-bar-danger" role = "progressbar" aria-valuenow = "35" aria-valuemin = "0" aria-valuemax = "100" style = "width: 35%;"> 35% (Danger) </div> </div> </div> </body>The output displays multiple Progress Bars in a single .progress class: |
|
| 35. |
How to create a tabbed navigation menu in Bootstrap? |
|
Answer» If you want to create a tabbed navigation MENU, then USE the “nav-tabs” class like this: <ul class="nav nav-tabs">Let us now see how we can form a tab based navigation menu: <!DOCTYPE html> <html lang="en"> <head> <title>Bootstrap Tabbed Menu</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"> <ul class="nav nav-tabs"> <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> </body> </html>The output looks like tabbed navigation menu as shown below. The Home tab is marked as the current page: |
|
| 36. |
How to change the size of the input groups in Bootstrap? |
|
Answer» The input group size can be easily changed in Bootstrap, using the .input-group-lg and input-group-sm, classes. Here, the .input-group-lg is used for large input groups. The .input-group-sm is used for small input groups. The following is an example that displays how to change the size of the input groups in Bootstrap: <!DOCTYPE html> <html lang="en"> <head> <title>Bootstrap Input Group Size</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>Input Group Size</h2> <form> <div class="input-group mb-3 input-group-sm"> <div class="input-group-prepend"> <span class="input-group-text">Small</span> </div> <input TYPE="NUMBER" class="form-control"> </div> </form> <form> <div class="input-group mb-3 input-group-lg"> <div class="input-group-prepend"> <span class="input-group-text">Large</span> </div> <input type="number" class="form-control"> </div> </form> </div> </body> </html>The output display different sizes of inputs: |
|
| 37. |
Link List Group Items in Bootstrap |
|
Answer» For List Group Items, we use the <ul> element as shown below: <ul class = "list-group"> <li class = "list-group-item">One</li> <li class = "list-group-item">Two</li> <li class = "list-group-item">Three</li> <li class = "list-group-item">Four</li> <li class = "list-group-item">Five</li> </ul>To LINK List Group Items, use the anchor tag. With that, use the <DIV> element INSTEAD of <ul>: <a href = "#" class = "list-group-item active">One</a> <a href = "#" class = "list-group-item">Two</a> <a href = "#" class = "list-group-item">Three</a> <a href = "#" class = "list-group-item">Four</a> <a href = "#" class = "list-group-item">Five</a>The following is an example displaying how you can link List Group Items: <!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>Link List Group Items</h2> <ul> <a href = "#" class = "list-group-item active">One</a> <a href = "#" class = "list-group-item">Two</a> <a href = "#" class = "list-group-item">Three</a> <a href = "#" class = "list-group-item">Four</a> <a href = "#" class = "list-group-item">Five</a> </ul> </div> </body> </html>The output is displayed here: We have used the .active class to display the CURRENT link. |
|
| 38. |
Why the justify-content-lg-around class used in Bootstrap 4? |
|
Answer» DISPLAY flex items around on LARGE SCREEN SIZE using the justify-content-lg-around class in Bootstrap. |
|
| 39. |
Which class is to be used to create Bordered Table? |
|
Answer» To create a bordered table, use the .table-bordered class. The bordered table will have borders on the sizes of the table and its cells. Here’s how you add a bordered table: <table class="table table-bordered"> … </table>The below example displays how we can create a bordered table: <!DOCTYPE HTML> <html lang="en"> <head> <title>Bootstrap Bordered 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-bordered"> <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> <tr> <td>WXA</td> <td>MN</td> </tr> </tbody> </table> </div> </body> </html>The above displays the following bordered table. We have here 7 rows and 2 columns: |
|
| 40. |
How to position tooltip in the bottom in Bootstrap? |
|
Answer» To POSITION tooltip in Bootstrap, use the data-placement attribute. To position tooltip in the bottom in Bootstrap, use the date-placement attribute with the FOLLOWING value: data-placement="bottom"The above will be used as: <a href="#" data-toggle="tooltip" data-placement="bottom" title="This is a tooltip!">Keep mouse cursor here</a>The following is how you can position tooltip in the bottom in Bootstrap: <!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"> <h3>Tooltip Example</h3> <p>Tooltip is in the bottom...</p><br> <a href="#" data-toggle="tooltip" data-placement="bottom" title="This is a tooltip!">Keep mouse cursor here</a> </div> <script> $(document).ready(function(){ $('[data-toggle="tooltip"]').tooltip(); }); </script> </body> </html>The following is the output that displays tooltip in the bottom: |
|
| 41. |
How to disable a button in Bootstrap? |
|
Answer» To disable a button in Bootstrap, use the .disabled class. Disabling a button makes it unclickable. The design changes will include fade in color by 50% and LOSING the gradient. Let us now see an example to disable a button in Bootstrap: <!DOCTYPE html> <html lang="en"> <HEAD> <title>Disable a Bootstrap Button</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>Disabling a Button</h2> <button type="button" class="btn btn-primary disabled">Disabled Button</button> <button type="button" class="btn btn-primary">Active Button</button> </div> </body> </html>The output displays a disabled and another button which is active. The disabled button is unclickable. You can check the same by placing MOUSE cursor on the disabled button: |
|
| 42. |
Why the align-content-sm-stretch class used in Bootstrap 4? |
|
Answer» STRETCH GATHERED items on small SCREEN USING the align-content-sm-stretch class USED in Bootstrap. |
|
| 43. |
Include links in Alerts in Bootstrap |
|
Answer» The .alert-LINK class is USED in Bootstrap to include links in Alerts. You need to use the anchor element: <a href="#" class="alert-link">Since we are using contextual CLASSES to color alerts, you need to provide matching colored links within any alert. 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"> <h2>Link in Alerts</h2> <div class="alert alert-success alert-dismissible"> <button type="button" class="close" data-dismiss="alert">×</button> <strong>Success! You cracked it!</strong> Demo <a href="#" class="alert-link"> Link!</a> </div> <div class="alert alert-info alert-dismissible"> <button type="button" class="close" data-dismiss="alert">×</button> <strong>Information! More Info!</strong> Demo <a href="#" class="alert-link"> Link!</a> </div> <div class="alert alert-warning alert-dismissible"> <button type="button" class="close" data-dismiss="alert">×</button> <strong>Warning! Close program to prevent system failure!</strong> Demo <a href="#" class="alert-link"> Link!</a> </div> <div class="alert alert-danger alert-dismissible"> <button type="button" class="close" data-dismiss="alert">×</button> <strong>Danger! Malware ahead!</strong> Demo <a href="#" class="alert-link"> Link!</a> </div> <div class="alert alert-primary alert-dismissible"> <button type="button" class="close" data-dismiss="alert">×</button> <strong>Primary!</strong> Demo <a href="#" class="alert-link"> Link!</a> </div> <div class="alert alert-secondary alert-dismissible"> <button type="button" class="close" data-dismiss="alert">×</button> <strong>Secondary!</strong> Demo <a href="#" class="alert-link"> Link!</a> </div> <div class="alert alert-dark alert-dismissible"> <button type="button" class="close" data-dismiss="alert">×</button> <strong>Dark alert!</strong> Demo <a href="#" class="alert-link"> Link!</a> </div> </div> </body> </html>The OUTPUT: Above, you can see the alert links have the same color as alerts. We added color to alerts using contextual classes. |
|
| 44. |
Which class is to be used in Bootstrap to display flex items from the beginning? |
|
Answer» Display FLEX items from the beginning using the justify-content-*-start class in BOOTSTRAP. For example, for large SCREEN size, use the class with lg: justify-content-lg-start |
|
| 45. |
How to create a carousel in Bootstrap? |
|
Answer» For CAROUSEL controls, we need an id. Here, we have: id="newCarousel"The following sets the <div> has a carousel: class="carousel slide"The data-ride="carousel" attribute begins animating the carousel when the page loads. The bottom of each slide has dots that indicates which slide you’re watching right now. The class .carousel-indicators specify it: <ol class="carousel-indicators"> <li data-target="#newCarousel" data-slide-to="0" class="active"></li> <li data-target="#newCarousel" data-slide-to="1"></li> <li data-target="#newCarousel" data-slide-to="2"></li> </ol>The slides are set with class .carousel-inner. We have set the next and previous controls as well with the data-slide attribute: <!--controls --> <a class="left carousel-control" href="#newCarousel" data-slide="prev"> <span class="glyphicon glyphicon-chevron-left"></span> <span class="sr-only">Previous</span> </a> <a class="right carousel-control" href="#newCarousel" data-slide="next"> <span class="glyphicon glyphicon-chevron-right"></span> <span class="sr-only">Next</span> </a>The following is an example: <!DOCTYPE html> <html lang="en"> <head> <title>Bootstrap Carousel</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>KnowledgeHut Blog</h2> <div id="newCarousel" class="carousel slide" data-ride="carousel"> <!-- Indicators --> <ol class="carousel-indicators"> <li data-target="#newCarousel" data-slide-to="0" class="active"></li> <li data-target="#newCarousel" data-slide-to="1"></li> <li data-target="#newCarousel" data-slide-to="2"></li> </ol> <div class="carousel-inner"> <div class="ITEM active"> <img src="https://d2o2utebsixu4k.cloudfront.net/media/images/599e46ac-60e1-429b-a305-e02574081e3c.jpg" alt="How To Pass Leading SAFe® 4 Exam" style="width:100%;"> </div> <div class="item"> <img src="https://d2o2utebsixu4k.cloudfront.net/media/images/079f81ac-d7f7-4c0c-8919-46cc1602c950.jpg" alt="Top-paying AGILE Certifications To Consider In 2018" style="width:100%;"> </div> <div class="item"> <img src="https://d2o2utebsixu4k.cloudfront.net/media/images/4096881a-05ea-4162-96cf-3e7949ea82a7.jpg" alt="DevOps In 5 letters: Should We Say CALMS or CALMR?" style="width:100%;"> </div> </div> <!--controls --> <a class="left carousel-control" href="#newCarousel" data-slide="prev"> <span class="glyphicon glyphicon-chevron-left"></span> <span class="sr-only">Previous</span> </a> <a class="right carousel-control" href="#newCarousel" data-slide="next"> <span class="glyphicon glyphicon-chevron-right"></span> <span class="sr-only">Next</span> </a> </div> </div> </body> </html>The output: Next slide in the carousel: |
|
| 46. |
How Progress Bar work in Bootstrap? |
|
Answer» PROGRESS Bar display loading or a process. It’s easy to crate Progress Bar with Bootstrap using some PREDEFINED classes. The .progress class is used in Bootstrap to create a Progress Bar. Include a .progress class to a <div> element. After that add an empty <div> with another class i.e. .progress-bar: <div class="progress"> <div class="progress-bar" role="progressbar" aria-valuenow="80" aria-valuemin="0" aria-valuemax="100" style="width:80%"> <span class="sr-only">80%</span> </div> </div>For users working with screen readers and to support accessibility, we have used aria-valuemin and aria-valuemax attributes. The above code will create the following Progress Bar: Above, we created a Progress Bar, but no information of the level of completion is visible. For that, you need to use label with Progress Bar. Let us see how to add a label to our Progress Bar: <!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>Level of impurities in WATER</h2> <div class="progress"> <div class="progress-bar" role="progressbar" aria-valuenow="80" aria-valuemin="0" aria-valuemax="100" style="width:80%"> 80% </div> </div> </div> </body> </html>The OUTPUT displays the % level visible on the Progress Bar since we have added label: |
|
| 47. |
Which Bootstrap class is used for labels? |
|
Answer» The .label class is used in Bootstrap to create labels. The purpose of using labels is to provide additional information. For example, mentioning “NEW” for a PRODUCT. It can also be used to set count, tips, etc. Let us see an example: <h1>Laptop Charger <span class = "label label-default"> NEW </span> </h1>To change the color of the label, use contextual classes: .label-default, .label-primary, .label-success, .label-info, .label-WARNING or .label-danger, etc. An example: <h1>Laptop Charger <span class = "label label-primary"> NEW </span> </h1>Above gives a BLUE color to the label since we have used the label-primary class. Now, we will work to create some more labels and color them: <!DOCTYPE html> <html lang="en"> <head> <title>Bootstrap Labels</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>Products Information</h2> <h2>Product 1 <span class="label label-default">20</span></h1> <h2>Product 2 <span class="label label-primary">30</span></h2> <h2>Product 3 <span class="label label-info">19</span></h2> <h2>Product 4 <span class="label label-success">50</span></h2> <h1>All the labels</h1> <span class="label label-default">Default Label</span> <span class="label label-primary">Primary Label</span> <span class="label label-success">Success Label</span> <span class="label label-info">Info Label</span> <span class="label label-warning">Warning Label</span> </div> </body> </html>The output |
|
| 48. |
Set a Panel with heading in Bootstrap |
|
Answer» To add a heading to a panel, use the .panel-heading class. Include it as a <div> class: <div class="panel-heading"> Panel Heading </div>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: |
|
| 49. |
Pills with Dropdowns in Bootstrap |
|
Answer» Pills based navigation can be created in Bootstrap. With that, we can also FORM Pills with Dropdowns. Create Pills with: <UL class="nav nav-pills">Use the class .nav-stacked to create Pills with Dropdowns: <ul class="nav nav-pills nav-stacked">Let us now see how we can create Pills with Dropdowns: <!DOCTYPE html> <html lang="en"> <head> <title>Bootstrap Pills with Dropdowns</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>Pills with Dropdown</h3> <ul class="nav nav-pills nav-stacked"> <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 class="dropdown"> <a class="dropdown-toggle" data-toggle="dropdown" href="#">Products <span class="caret"></span> </a> <ul class="dropdown-menu"> <li><a href="#">Product1</a></li> <li><a href="#">PRODUCT2</a></li> <li><a href="#">Product3</a></li> <li><a href="#">Product4</a></li> <li><a href="#">Product5</a></li> </ul> </li> <li><a href="#">Contact</a></li> </ul> </div> </body> </html>The following is an example: |
|
| 50. |
Create an Image Thumbnail in Bootstrap |
|
Answer» Image thumbnail looks different from a regular image on a website. It has a gray border and PADDING, which MAKES it separate from other images. The following is an example that displays an image as a thumbnail in Bootstrap USING the img-thumbnail class: <!DOCTYPE html> <html lang="EN"> <head> <title>Bootstrap Thumbnail 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 a thumbnail image with gray border and padding.</p> <img class="img-thumbnail" src="https://d2o2utebsixu4k.cloudfront.net/media/images/7d7b2bef-2512-4a87-96cb-0bafd0da5048.jpg" alt="Chania" width="460" height="345"> </div> </body> </html>The output: |
|