Bootstrap Navabar + Purex 菜单错位
Bootstrap navbar + purecss menu misalignment
我有一个 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>
您可以将 width: 100%;
添加到 .pure-menu-children
ul,它会展开全角。
.pure-menu-horizontal .pure-menu-children {
width: 100%;
}
我有一个 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>
您可以将 width: 100%;
添加到 .pure-menu-children
ul,它会展开全角。
.pure-menu-horizontal .pure-menu-children {
width: 100%;
}