BootStrap Advanced #2
DropDowns:
A dropdown menu is a toggleable menu that allows the user to choose one value from a predefined list
The .dropdown
class indicates a dropdown menu.
To open the dropdown menu, use a button or a link with a class of .dropdown-toggle
and the data-toggle="dropdown"
attribute.
Add the .dropdown-menu
class to a <div>
element to actually build the dropdown menu. Then add the .dropdown-item
class to each element (links or buttons) inside the dropdown menu.
Example :
<div class="dropdown">
<button type="button" class="btn btn-primary dropdown-toggle" data-toggle="dropdown">
Dropdown button
</button>
<div class="dropdown-menu">
<a class="dropdown-item" href="#">Link 1</a>
<a class="dropdown-item" href="#">Link 2</a>
<a class="dropdown-item" href="#">Link 3</a>
</div>
</div>
The .dropdown-divider
class is used to separate links inside the dropdown menu with a thin horizontal border
Example:
<div class="dropdown-divider"></div>
Collapse:
Collapsibles are useful when you want to hide and show large amount of content
Example:
<button data-toggle="collapse" data-target="#demo">Collapsible</button>
<div id="demo" class="collapse">
Lorem ipsum dolor text....
</div>
The .collapse
class indicates a collapsible element (a <div> in our example); this is the content that will be shown or hidden with a click of a button.
To control (show/hide) the collapsible content, add the data-toggle="collapse"
attribute to an <a> or a <button> element. Then add the data-target="#id"
attribute to connect the button with the collapsible content (<div id="demo">)
By default, the collapsible content is hidden. However, you can add the .show
class to show the content by default.
Example:
<div id="demo" class="collapse show">
Lorem ipsum dolor text....
</div>
<div id="demo" class="collapse show">
Lorem ipsum dolor text....
</div>
Navigation Menu:
If you want to create a simple horizontal menu, add the .nav
class to a <ul>
element, followed by .nav-item
for each <li>
and add the .nav-link
class to their links
Example:
<ul class="nav">
<li class="nav-item">
<a class="nav-link" href="#">Link</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Link</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Link</a>
</li>
<li class="nav-item">
<a class="nav-link disabled" href="#">Disabled</a>
</li>
</ul>
Add the .justify-content-center
class to center the nav, and the .justify-content-end
class to right-align the nav.
Example:
<!-- Centered nav -->
<ul class="nav justify-content-center">
<!-- Right-aligned nav -->
<ul class="nav justify-content-end">
Add the .flex-column
class to create a vertical nav.
NavBar:
A navigation bar is a navigation header that is placed at the top of the page.
A standard navigation bar is created with the .navbar
class, followed by a responsive collapsing class: .navbar-expand-xl|lg|md|sm
(stacks the navbar vertically on extra large, large, medium or small screens)
Example:
<nav class="navbar navbar-expand-sm bg-light">
<!-- Links -->
<ul class="navbar-nav">
<li class="nav-item">
<a class="nav-link" href="#">Link 1</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Link 2</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Link 3</a>
</li>
</ul>
</nav>
Remove the .navbar-expand-xl|lg|md|sm
class to create a vertical navigation bar.
Comments
Post a Comment