我一直试图解决这个问题一段时间了。如果我真的在视觉上代表它,我将能够解释它:
我正在尝试垂直对齐导航栏。
我尝试使用align-self
,但似乎没有任何改变。
/* Navigation */
.navigation {
overflow: hidden;
margin: 0;
align-self: center;
}
.navigation a {
display: block;
float: right;
color: #f2f2f2;
text-align: center;
text-decoration: none;
font-family: 'Quicksand', sans-serif;
font-size: 1rem;
}
.navigation a:hover {
background-color: #ddd;
color: black;
}
/* Hide the link that should open and close the navigation on small screens */
.navigation .icon {
display: none;
}
这是我与我的css混淆的情况,还是div定位不正确的情况?
<!-- Navigation bar -->
<div class="navigation" id="myNavigation">
<a href="index.html">Home</a>
<a href="#services">About Me</a>
<a href="#about-me">Services</a>
<a href="#portfolio">Portfolio</a>
<a href="#contact">Contact</a>
<a href="javascript:void(0);" class="icon" onclick="openNavigation()">☰</a>
</div>
</div>
答案 0 :(得分:0)
好的,所以我找到了解决方案。我需要制作我的css网格display: flex
和align-items: center
。