Home >Web Front-end >Bootstrap Tutorial >How to add breadcrumb navigation in Bootstrap? Brief analysis of methods
How to add breadcrumb navigation in
Bootstrap? The following article will introduce to you how to use the Bootstrap5 breadcrumb navigation component. I hope it will be helpful to you!
Breadcrumb navigation is generally used under the navigation bar at the top of the website to indicate the level of the current page in the navigation hierarchy. Generally used > Or | and space separation, Bootstrap5 breadcrumb navigation automatically adds separators through CSS. [Related recommendations: "bootstrap Tutorial"]
In the picture below, the row of small navigation below the navigation bar is a common breadcrumb navigation
Example
<!doctype html> <html> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="keywords" content=""> <meta name="description" content=""> <link href="bootstrap5/bootstrap.min.css" rel="stylesheet"> <title>面包屑演示</title> </head> <body> <br><br> <nav aria-label="breadcrumb"> <ol> <li><a href="#">首页</a></li> <li><a href="#">新闻</a></li> <li class="breadcrumb-item active" aria-current="page">国内新闻</li> </ol> </nav> <script src="bootstrap5/bootstrap.bundle.min.js" ></script> </body> </html>
In the following code, add a style="--bs-breadcrumb-divider: '>';"
You can use > as the dividing symbol, or you can change it to any other character .
<!doctype html> <html> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="keywords" content=""> <meta name="description" content=""> <link href="bootstrap5/bootstrap.min.css" rel="stylesheet"> <title>面包屑演示</title> </head> <body> <br><br> <nav style="--bs-breadcrumb-divider: '>';" aria-label="breadcrumb"> <ol> <li><a href="#">首页</a></li> <li><a href="#">新闻</a></li> <li class="breadcrumb-item active" aria-current="page">国内新闻</li> </ol> </nav> <nav style="--bs-breadcrumb-divider: '|';" aria-label="breadcrumb"> <ol> <li><a href="#">首页</a></li> <li><a href="#">新闻</a></li> <li class="breadcrumb-item active" aria-current="page">国内新闻</li> </ol> </nav> <nav style="--bs-breadcrumb-divider: '-';" aria-label="breadcrumb"> <ol> <li><a href="#">首页</a></li> <li><a href="#">新闻</a></li> <li class="breadcrumb-item active" aria-current="page">国内新闻</li> </ol> </nav> <script src="bootstrap5/bootstrap.bundle.min.js" ></script> </body> </html>
The above example can also use embedded SVG icons.
<nav style="--bs-breadcrumb-divider: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='8'%3E%3Cpath d='M2.5 0L1 1.5 3.5 4 1 6.5 2.5 8l4-4-4-4z' fill='currentColor'/%3E%3C/svg%3E");" aria-label="breadcrumb"> <ol class="breadcrumb"> <li class="breadcrumb-item"><a href="#">首页</a></li> <li class="breadcrumb-item"><a href="#">新闻</a></li> <li class="breadcrumb-item active" aria-current="page">国内新闻</li> </ol> </nav>
You can also remove the separator setting--bs-breadcrumb-divider: '';(CSS custom property Empty strings in will be counted as one value).
<nav style="--bs-breadcrumb-divider: '';" aria-label="breadcrumb"> <ol class="breadcrumb"> <li class="breadcrumb-item"><a href="#">首页</a></li> <li class="breadcrumb-item"><a href="#">新闻</a></li> <li class="breadcrumb-item active" aria-current="page">国内新闻</li> </ol> </nav>
For more knowledge about bootstrap, please visit: bootstrap basic tutorial! !
The above is the detailed content of How to add breadcrumb navigation in Bootstrap? Brief analysis of methods. For more information, please follow other related articles on the PHP Chinese website!