The key to making the Bootstrap bottom navigation bar is to have a clear structure and correct style. First, use the nav elements to cooperate with the .nav and .nav-pills classes to build the basic structure, and use fixed-bottom to fix the navigation at the bottom; second, arrange the ul and li elements in HTML, and combine the active classes to select highlights; then, use mx-auto to center the content, and optimize the visual effects to the mobile terminal adaptation with the Font Awesome icon and responsive class; finally, pay attention to avoid using navbar-nav and deal with content occlusion and compatibility issues caused by fixed positioning, so as to achieve a practical and beautiful bottom navigation bar.
It is actually not difficult to make the Bootstrap bottom navigation bar, the key is the clear structure and correct style. As long as you master the basic HTML structure and how to use Bootstrap classes, you can quickly implement a responsive bottom navigation.

Basic structure: use nav nav-pills or nav-tabs
Bootstrap's navigation components are usually built based on the <nav></nav>
element and .nav
class. To create a bottom navigation, .nav-pills
is recommended because it is more suitable for button navigation in vertical or horizontal arrangements.
The HTML structure is roughly as follows:

<nav class="navbar fixed-bottom bg-light"> <ul class="nav nav-pills mx-auto"> <li class="nav-item"> <a class="nav-link" href="#">Home</a> </li> <li class="nav-item"> <a class="nav-link" href="#">Category</a> </li> <li class="nav-item"> <a class="nav-link" href="#">My</a> </li> </ul> </nav>
- Use
fixed-bottom
to fix navigation at the bottom of the page. -
mx-auto
is to center the navigation content. - If you want the selected item to be highlighted, remember to add the
active
class.
Style adjustment: adapted to mobile terminal and beautiful processing
Although Bootstrap provides default styles, sometimes we want the navigation to look more like the "bottom tab bar", such as a style similar to the mobile app.
You can consider the following points:

Use smaller fonts and icons, such as Font Awesome:
<a class="nav-link" href="#"> <i class="fas fa-home"></i> <span class="d-block">Home Page</span> </a>
Set the width of
.nav-link
to be consistent to avoid the text length affecting the layout.Hiding text on mobile only shows icons (or vice versa). You can use Bootstrap's responsive tool class such as
d-none d-md-block
.Adjust padding and margin to make the overall vision more compact.
Don't use navbar-nav directly
Because.navbar-nav
is arranged vertically by default, while bottom navigation usually requires horizontal arrangement, it is recommended to use.nav
with.nav-pills
directly.Fixed positioning causes content to be blocked
After usingfixed-bottom
, the content of the page may be blocked by the navigation bar. You can add amargin-bottom
to the main content area, which is slightly larger than the navigation bar height.Compatibility issues
In some older browsers, the flex layout may behave abnormally, and it is recommended to test mainstream devices and browsers.
Note: Don't step on these pitfalls
Basically that's it. Following the above structure and method, you can easily create a practical and beautiful bottom navigation bar in Bootstrap.
The above is the detailed content of How to make a bottom navbar in Bootstrap?. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undress AI Tool
Undress images for free

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

TheBootstrapGridSystemisaresponsive,mobile-firstgridsystemthatsimplifiescreatingcomplexlayoutsforwebdevelopment.Itusesa12-columnlayoutandoffersflexibilityfordifferentscreensizes,ensuringvisuallyappealingdesignsacrossdevices.

Bootstrapsimplifiescreatingresponsiveandelegantforms.Keypointsinclude:1)Startwithbasicformcomponentsforintuitivedesign.2)Customizeformsforcompactnessorspecificneeds.3)Implementbothclient-sideandserver-sidevalidationforsecurity.4)Optimizeperformanceby

The advantage of creating forms with Bootstrap is that it provides a consistent and responsive design, saving time, and ensuring cross-device compatibility. 1) Basic forms are simple to use, such as form-control and btn classes. 2) Vertical forms achieve a more structured layout through grid classes (such as col-sm-2 and col-sm-10).

TheBootstrapGridSystemcanbeoptimizedforbetteraccessibility.1)UsesemanticHTMLtagslikeandinsteadofgenericelements.2)ImplementARIAattributestoenhancescreenreaderfunctionality.3)ManagefocusorderlogicallywithBootstrap'sorderclasses.4)Useutilityclassesforp

BootstrapGridSystemisbetterforquick,simpleprojects;Flexboxisidealforcustomizationandcontrol.1)Bootstrapiseasiertouseandfastertoimplement.2)Flexboxoffersmorecustomizationandflexibility.3)Flexboxcanbemoreperformant,butthedifferenceisusuallyminor.4)Boot

Bootstrapformscanleadtoerrorslikemisusingthegridsystem,improperformcontrols,validationissues,neglectingcustomCSS,accessibility,andperformance.Toavoidthese:1)Usecolumnclasseslikecol-sm-orcol-md-forresponsiveness;2)Wrapinputfieldsin.form-groupforproper

The dropdown menu of BootstrapNavbar can be implemented through the following steps: 1. Use the dropdown class and the data-bs-toggle="dropdown" attribute. 2. Ensure responsive design. 3. Optimize performance. 4. Improve accessibility. 5. Custom style. This helps create a user-friendly navigation system.

Bootstrap'sGridSystemhelpsinbuildingresponsivelayoutsbyofferingflexibilityandeaseofuse.1)Itallowsquickcreationofadaptablelayoutsacrossdevices.2)Advancedfeatureslikenestedrowsenablecomplexdesigns.3)Itencouragesaresponsivedesignphilosophy,enhancingcont
