移动导航是偏移的,高度不需要100VH
我正在尝试使我的导航填充整个屏幕(它将隐藏在右上角并滑到中心),但是它的左侧有这个怪异的边距。
另外高度:100VH;
它不采用100%的视图高度。
@import url("https://fonts.googleapis.com/css2?family=Barlow:wght@400;700&family=Fraunces:opsz,[email protected],400;9..144,700&display=swap");
*,
*::before,
*::after {
margin: 0;
padding: 0;
box-sizing: border-box;
}
header {
background-color: aquamarine;
height: 3.5rem;
padding: 0 1rem;
width: 100%;
display: flex;
justify-content: space-between;
align-items: center;
}
.open-menu, .close-menu {
font-size: 2rem;
}
nav {
background-color: bisque;
height: 100vh;
width: 100vw;
position: fixed;
}
<header class="menu">
<h1>Logo</h1>
<nav class="nav">
<ul>
<li><a href="#" class="links">About</a></li>
<li><a href="#" class="links">Services</a></li>
<li><a href="#" class="links">Projects</a></li>
<li><a href="#" class="links cta">Contact</a></li>
</ul>
<button class="close-menu">
close
</button>
</nav>
<button class="open-menu">
open
</button>
</header>
I'm trying to make my nav fill the entire screen (it will be hidden in right corner and slide to the center) but it has this weird margin on the left side.
Also height: 100vh;
it's not taking 100% view height.
@import url("https://fonts.googleapis.com/css2?family=Barlow:wght@400;700&family=Fraunces:opsz,[email protected],400;9..144,700&display=swap");
*,
*::before,
*::after {
margin: 0;
padding: 0;
box-sizing: border-box;
}
header {
background-color: aquamarine;
height: 3.5rem;
padding: 0 1rem;
width: 100%;
display: flex;
justify-content: space-between;
align-items: center;
}
.open-menu, .close-menu {
font-size: 2rem;
}
nav {
background-color: bisque;
height: 100vh;
width: 100vw;
position: fixed;
}
<header class="menu">
<h1>Logo</h1>
<nav class="nav">
<ul>
<li><a href="#" class="links">About</a></li>
<li><a href="#" class="links">Services</a></li>
<li><a href="#" class="links">Projects</a></li>
<li><a href="#" class="links cta">Contact</a></li>
</ul>
<button class="close-menu">
close
</button>
</nav>
<button class="open-menu">
open
</button>
</header>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不太确定为什么,但是使用
解决了问题
I'm not exacly sure why, but using
solved the problem