Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/453.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何在使用引导(html、css)时将固定顶部更改为相对顶部_Javascript_Html_Css - Fatal编程技术网

Javascript 如何在使用引导(html、css)时将固定顶部更改为相对顶部

Javascript 如何在使用引导(html、css)时将固定顶部更改为相对顶部,javascript,html,css,Javascript,Html,Css,我在html页面中使用了引导导航栏 我使用了“fixed top”类,因此我的导航栏将固定在顶部—— <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&g

我在html页面中使用了引导导航栏

我使用了“fixed top”类,因此我的导航栏将固定在顶部——

<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已修复
,但在HTML中不使用它。尝试将
.top fixed
类添加到html元素或使用
.css中的固定top

bootstrap4使用!在几乎每一行中都很重要,所以一个解决方案是在自定义css中也使用它(position:relative!important),很难说没有看到其他选择器。使用css关于选择器特异性和级联的知识来找出原因。另外,请检查浏览器开发工具,这可能会有所帮助。我会在页面加载时使用并删除
固定顶部
类。HTML和CSS中的类不匹配。
.top-fixed{
  position: relative;
}