这是我的菜单切换部分:
JS小提琴
菜单看起来像这样
问题:
使切换按钮(菜单图标)在容器中对齐有什么变化?仅 CSS<div class="navigation"></div>
为了更好的想象这里是对齐文本(左,右,中心)
HTML:
<div class="navigation">
<div id="slidebox">
<div id="toggle">
<a href="#">☰</a>
<a class="top" href="#slidebox">☰</a>
</div>
<ul id="box" class="menu">
<li><a href="#">Homepage</a></li>
<li><a href="#">About Us</a></li>
<li><a href="#">Contact Us</a></li>
</ul>
</div>
</div>
CSS:
/* TOGGLE */
#slidebox {
position: relative;
padding: 0;
margin: 0;
display: block;
width: 100%;
}
#toggle {
height: 50px;
padding: 0;
position: relative;
background: #0292a8;
display: none;
text-align: center;
}
@media screen and (max-width: 640px) {
#toggle {
display: block;
}
}
#toggle a {
position: absolute;
text-decoration: none;
line-height: 50px;
font-size: 16px;
color: #fff;
}
#box {
padding: 0;
margin: 0;
position: relative;
width: 100%;
display: block;
}
@media screen and (max-width: 640px) {
#box {
display: none;
}
}
#slidebox:target #box {
min-height: 100%;
display: block;
opacity: 1;
}
#slidebox:target .top {
pointer-events: none;
display: none;
}