gpt4 book ai didi

BootStrap笔记-下拉菜单的使用

转载 作者:知者 更新时间:2024-03-13 08:59:11 26 4
gpt4 key购买 nike

运行截图如下:

代码如下;

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>CN_TEST1</title>
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">

<!--    bootstrap css核心文件-->
    <link rel="stylesheet" href="bootstrap-4.4.1-dist/css/bootstrap.min.css">
<!--    bootstrap使用到了jquery,需要提前引用-->
    <script src="js/jquery-3.5.1.min.js"></script>
<!--    弹窗、提示、下拉菜单-->
    <script src="bootstrap-4.4.1-dist/js/bootstrap.bundle.js"></script>
<!--    bootstrap核心文件-->
    <script src="bootstrap-4.4.1-dist/js/bootstrap.min.js"></script>

</head>
<body>

    <div class="container-fluid">

        <div class="dropdown">
            <button type="button" class="btn btn-primary dropdown-toggle" data-toggle="dropdown">
                DropDown
            </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>

        <br/>

        <div class="dropdown">

            <a class="btn btn-secondary dropdown-toggle" href="#" role="button" id="dropdownMenuLink" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                Dropdown
            </a>

            <div class="dropdown-menu" aria-labelledby="dropdownMenuLink">
                <div class="dropdown-header">Dropdown header 1</div>
                <a class="dropdown-item" href="#">Link 1</a>
                <a class="dropdown-item" href="#">Link 2</a>
                <div class="dropdown-divider"></div>
                <a class="dropdown-item disabled" href="#">Link 3</a>
            </div>
        </div>

        <br/>
        

    </div>

</body>
</html>

解释:

①实现下拉菜单的逻辑先在div中设置dropdown-menu,再到里面一层放dropdown-item;

26 4 0