我在我的 html 页面中使用了引导导航栏。
我使用了“固定顶部”类,所以我的导航栏将固定在顶部 –
<div class="container">
<nav class="nav navbar-expand-lg navbar-light bg-light text-center justify-content-center fixed-top">
<a class="navbar-brand" href="#">Navbar1</a>
<a class="navbar-brand" href="#">Navbar2</a>
<a class="navbar-brand" href="#">Navbar3</a>
</nav>
</div>
但在移动演示中,我希望它再次成为position:relative - 我该如何实现?
我试着在媒体查询中这样写:
.top-fixed{
position: relative;
}
但导航栏保持固定。
谢谢!
.top-fixed {
position: relative;
}
<div class="container">
<nav class="nav navbar-expand-lg navbar-light bg-light text-center justify-content-center fixed-top">
<a class="navbar-brand" href="#">Navbar1</a>
<a class="navbar-brand" href="#">Navbar2</a>
<a class="navbar-brand" href="#">Navbar3</a>
</nav>
</div>
最佳答案
因为你试图通过类名 .top-fixed
来偷偷摸摸,但你没有在 HTML 中使用它。尝试将 .top-fixed
类添加到 html 元素或在 css 中使用 .fixed-top
类
关于javascript - 如何在使用 Bootstrap (html、css)时将固定顶部更改为相对,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59684094/