这是我创建的CSS菜单。
当我在手机(iPhone 6)中看到此内容时,最后一个菜单(Menu4)并未显示At All。前3个菜单从电话屏幕的左侧延伸到右侧。我无法弄清楚原因。
有人可以帮忙吗?
这是HTML部分
<hr class="navHr">
<nav id="m">
<a href="#" data-mirror="Menu1">Menu1</a>
<a href="#" data-mirror="Menu2">Menu2</a>
<a href="#" data-mirror="Menu3">Menu3</a>
<a href="#" data-mirror="Menu4">Menu4</a>
</nav>
<hr class="navHr">
CSS部分
.navHr {
border: 0;
height: 0.1em;
margin: 0;
background-image: -webkit-linear-gradient(left, rgba(0,0,0,0), rgba(0,0,0,0.75), rgba(0,0,0,0));
background-image: -moz-linear-gradient(left, rgba(0,0,0,0), rgba(0,0,0,0.75), rgba(0,0,0,0));
background-image: -ms-linear-gradient(left, rgba(0,0,0,0), rgba(0,0,0,0.75), rgba(0,0,0,0));
background-image: -o-linear-gradient(left, rgba(0,0,0,0), rgba(0,0,0,0.75), rgba(0,0,0,0));
}
nav {
height: 2em;
background: #000;
background: linear-gradient(to bottom, rgba(76, 76, 76, 1) 0%, rgba(44, 44, 44, 1) 50%, rgba(0, 0, 0, 1) 51%, rgba(19, 19, 19, 1) 100%);
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#4c4c4c', endColorstr='#131313',GradientType=0 );
line-height: 2em;
text-transform: uppercase;
text-align: center;
min-width: 2em;
position: relative;
}
nav::before {
background: linear-gradient(to top, rgba(76, 76, 76, 0) 0%, rgba(44, 44, 44, 1) 50%, rgba(0, 0, 0, 1) 51%, rgba(19, 19, 19, 1) 100%);
content: '';
display: block;
position: absolute;
top: 100%;
left: 0;
width: 100%;
height: 100%;
opacity: 0.09;
}
nav a {
color: #FFF;
text-decoration: none;
font-weight: bold;
font-size: 1.2em;
border-right: solid 0.1em #FFF;
height: 100%;
padding: 0.25em 3em;
position: relative;
}
nav a:first-child {
border-left: solid 0.1em #FFF;
}
nav a::before {
content: attr(data-mirror);
position: absolute;
top: 100%;
left: 3em;
color: #000;
transform: scaleY(-1);
color: #FFF;
opacity: 0.5;
}
#m {
background-color: #000000;
}
答案 0 :(得分:1)
我已检查了您的代码,尝试在"display:inline-block"
上添加anchor tag
,您会看到第4列出现,第4列在小屏幕下方,因为位置是relative
,请在此处尝试:
基本上,您正在寻找的是将元素显示为内联级块容器以避免错位。该块的内部被格式化为块级框,并且元素本身被格式化为内联级框,其形成彼此相邻的这4列的导航。
为什么我们使用inline-block
?