Home > Web Front-end > Bootstrap Tutorial > How to write bootstrap drop-down menu

How to write bootstrap drop-down menu

下次还敢
Release: 2024-04-05 01:54:22
Original
595 people have browsed it

Bootstrap drop-down menu is a menu component that expands submenus downwards. The creation method is as follows: Create a parent menu item and add "dropdown-toggle" and "data-toggle="dropdown"" attributes. Create dropdown content and use the "dropdown-menu" class to wrap the dropdown menu items. Add dropdown content to parent menu item. Add "dropdown-menu-right" or "dropdown-menu-left" aligned dropdown menus. Add "divider" class to separate menu items. Add "dropdown-header" class to create header.

How to write bootstrap drop-down menu

Bootstrap drop-down menu

The drop-down menu is a menu component provided by Bootstrap, which can realize the submenu from the parent menu. The effect of menu items expanding downward is a common element in building navigation bars and user interfaces.

How to create a Bootstrap drop-down menu

    <li>

    Create a parent menu item:Use<a> The element wraps the menu item content and adds the dropdown-toggle class and data-toggle="dropdown" attribute to it.

    <a class="dropdown-toggle" data-toggle="dropdown" href="#">菜单项</a>
    Copy after login
    <li>

    Create drop-down content: Use the <ul> element to wrap the drop-down menu item and add dropdown-menu to it kind.

    <ul class="dropdown-menu">
      <li><a href="#">子菜单项1</a></li>
      <li><a href="#">子菜单项2</a></li>
      <li><a href="#">子菜单项3</a></li>
    </ul>
    Copy after login
    <li>

    Add the drop-down content to the parent menu item: Nest the <ul> element inside <a&gt Behind the ; element, a drop-down menu structure is formed.

    <a class="dropdown-toggle" data-toggle="dropdown" href="#">菜单项
      <ul class="dropdown-menu">
     <li><a href="#">子菜单项1</a></li>
     <li><a href="#">子菜单项2</a></li>
     <li><a href="#">子菜单项3</a></li>
      </ul>
    </a>
    Copy after login
    <li>

    Add alignment: This can be done by adding the dropdown-menu-right or dropdown-menu-left class to adjust the alignment of the drop-down menu.

    <a class="dropdown-toggle" data-toggle="dropdown" href="#">菜单项
      <ul class="dropdown-menu dropdown-menu-right">
     <li><a href="#">子菜单项1</a></li>
     <li><a href="#">子菜单项2</a></li>
     <li><a href="#">子菜单项3</a></li>
      </ul>
    </a>
    Copy after login
    <li>

    Add separator: You can use the <li> element and add the divider class to it Add separator.

    <ul class="dropdown-menu">
      <li><a href="#">子菜单项1</a></li>
      <li class="divider"></li>
      <li><a href="#">子菜单项3</a></li>
    </ul>
    Copy after login
    <li>

    Add a header: You can use the <li> element and add the dropdown-header class to it to add a title.

    <ul class="dropdown-menu">
      <li><a href="#">子菜单项1</a></li>
      <li class="dropdown-header">标题</li>
      <li><a href="#">子菜单项3</a></li>
    </ul>
    Copy after login

The above is the detailed content of How to write bootstrap drop-down menu. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
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
Latest Issues
There is no bootstrap custom video tutorial
From 1970-01-01 08:00:00
0
0
0
Laravel: Problem using bootstrap locally
From 1970-01-01 08:00:00
0
0
0
html5 - Problem with bootstrap modifying style
From 1970-01-01 08:00:00
0
0
0
Introducing bootstrap is invalid
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template