How to add breadcrumb navigation in Bootstrap? Brief analysis of methods

青灯夜游
Release: 2021-11-25 19:41:45
forward
2627 people have browsed it

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!

How to add breadcrumb navigation in Bootstrap? Brief analysis of methods

1 Breadcrumb navigation

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

How to add breadcrumb navigation in Bootstrap? Brief analysis of methods

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>
Copy after login

How to add breadcrumb navigation in Bootstrap? Brief analysis of methods

2 Custom separator

2.1 By modifying local CSS custom properties

In the following code, add a style="max-width:90%">';"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: &#39;>&#39;;" 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: &#39;|&#39;;" 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: &#39;-&#39;;" 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>
Copy after login

How to add breadcrumb navigation in Bootstrap? Brief analysis of methods

2.2 Using icons or images

The above example can also use embedded SVG icons.

 <nav   style="max-width:90%" 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>
Copy after login

How to add breadcrumb navigation in Bootstrap? Brief analysis of methods

2.3 Do not use separator

You can also remove the separator setting--bs-breadcrumb-divider: '';(CSS custom property Empty strings in will be counted as one value).

<nav   style="max-width:90%" 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>
Copy after login

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!

Related labels:
source:juejin.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template