Bootstrap 导航覆盖

Bootstrap navigation override

我目前正在尝试覆盖我的 bootstrap 导航默认样式,出于某种原因,这不起作用。我已将 !important 标记添加到我的 CSS 中,因为这似乎是最合乎逻辑的方法?但它没有用。我希望有人能够帮助我!

HTML:

<nav class="navbar navbar-expand-lg navbar-light">
    <div class="container-fluid">
        <a class="navbar-brand" href="#"> <img src="/Assets/logo.svg" class="me-5" alt="" height="80"> </a>
        <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs- target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria- expanded="false" aria-label="Toggle navigation"> <span class="navbar-toggler-icon"></span> </button>
        <div class="collapse navbar-collapse" id="navbarSupportedContent">
            <ul class="navbar-nav me-auto mb-2 mb-lg-0">
                <li class="nav-item"> <a class="nav-link active" aria-current="page" href="#">Home</a> </li>
                <li class="nav-item"> <a class="nav-link" href="#">Link</a> </li>
                <li class="nav-item dropdown"> <a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-bs-toggle="dropdown" aria-expanded="false">
            Dropdown
          </a>
                    <ul class="dropdown-menu" aria-labelledby="navbarDropdown">
                        <li><a class="dropdown-item" href="#">Action</a></li>
                        <li><a class="dropdown-item" href="#">Another action</a></li>
                        <li>
                            <hr class="dropdown-divider">
                        </li>
                        <li><a class="dropdown-item" href="#">Something else here</a></li>
                    </ul>
                </li>
                <li class="nav-item"> <a class="nav-link disabled" href="#" tabindex="-1" aria-disabled="true">Disabled</a> </li>
            </ul>
        </div>
    </div>
</nav>

CSS

.navbar{
    background-color: #ffffff10 !important;  
    backdrop-filter: blur(12px) !important;  
    -webkit-backdrop-filter: blur(12px) !important;  
}

如果我理解你清楚:

您的 css 正在运行,但我猜您在屏幕上看不到任何差异。 因为您必须将背景 img 提供给后面的对象。

enter image description here

试试这个:

 body {
        background-image: url("https://www.lg.com/tr/images/TV/features/D04_TV-UHD-UM75-04-Quad-Core-Processor-Desktop.jpg");
    }
    .navbar
        {
            border:1px solid red;
    background-color: #ffffff10 !important;  
    
    backdrop-filter: blur(12px) !important;  
    -webkit-backdrop-filter: blur(12px) !important;  
}

和一些例子 https://css-tricks.com/almanac/properties/b/backdrop-filter/ https://css-tricks.com/almanac/properties/b/backdrop-filter/

如果您无法覆盖 css class,您可以使用 ID 选择器。因为 id 优先于 class.

#navbar
    { color:red;}

如果我理解错了,请分享代码笔 link-or 文件