gpt4 book ai didi

html - Bootstrap navbar + purecss 菜单错位

转载 作者:太空宇宙 更新时间:2023-11-04 05:43:31 27 4
gpt4 key购买 nike

我有一个 bootstrap 站点,我在其中使用 purecss 作为下拉菜单,并将其包装在 bootstrap 导航栏中,使其成为一个粘性导航栏。悬停下拉菜单时,会出现错位。如何纠正?

.navbar {
position: fixed;
left: 0;
right: 0;
top: 0;
z-index: 1000;
width: 100%;
text-align: right;
}
<link href="https://unpkg.com/purecss@1.0.1/build/pure-min.css" rel="stylesheet"/>
<link href="https://bootswatch.com/4/darkly/bootstrap.min.css" rel="stylesheet"/>
<body>
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<div class="pure-u-1 pure-u-md-1-3">
<div class="pure-menu pure-menu-horizontal">
<ul class="pure-menu-list">
<li class="pure-menu-item pure-menu-selected"><a href="#" class="pure-menu-link">Home</a></li>
<li class="pure-menu-item pure-menu-has-children pure-menu-allow-hover">
<a href="#" id="menuLink1" class="pure-menu-link">Main</a>
<ul class="pure-menu-children">
<li class="pure-menu-item"><a href="#" class="pure-menu-link">page 1</a></li>
<li class="pure-menu-item"><a href="#" class="pure-menu-link">page 2</a></li>
<li class="pure-menu-item"><a href="#" class="pure-menu-link">page 3</a></li>
</ul>
</li>
</ul>
</div>
</div>
</nav>
</body>

screenshot

最佳答案

您可以将 width: 100%; 添加到 .pure-menu-children ul 中,它会展开整个宽度。

.pure-menu-horizontal .pure-menu-children {
width: 100%;
}

关于html - Bootstrap navbar + purecss 菜单错位,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58925748/

27 4 0