我正在使用css和html为移动设备制作标签。我当前的代码显示了一些奇怪的行为。我当前的代码显示了下面图片中显示的选项卡。您可以看到标签都放错了位置,这些标签内的图标略微位于右侧,但我希望它位于标签的中心。我可以将图标向左移动以使其显示在photoshop的中心,但如果我在大屏幕移动设备上测试此应用程序,则此图标将显示在左侧。我希望他们永远在中心。那么请告诉我如何像普通移动应用程序那样制作更好的标签?
这是mu html代码
<footer>
<ul>
<li class="tabs"><a href="#"></a></li>
<li class="tabs"><a href="#"></a></li>
<li class="tabs"><a href="#"></a></li>
</ul>
</footer>
这是我的css
footer {
position: absolute;
z-index: 2;
bottom: 0;
left: 0;
width: 100%;
height: 50px;
padding: 0;
background: #535353;
}
footer ul {
list-style-type: none;
margin: 0;
padding: 0;
}
footer ul li {
display: inline-block;
width: 31%;
height: 50px;
}
footer ul li a {
display: block;
text-decoration: none;
height: 100%;
width: 100%;
background: #fff;
background: url(../../../img/tabs.png) top left no-repeat;
}
这是图像:
更新
这是我的新css
footer {
position: absolute;
z-index: 2;
bottom: 0;
left: 0;
width: 100%;
height: 50px;
padding: 0;
background: #ccc; }
footer ul {
list-style-type: none;
margin: 0;
padding: 0;
text-align: center; }
footer ul li {
display: block;
float: left;
width: 33.33%;
line-height: 50px;
text-align: center;
overflow: hidden; }
footer ul li a {
display: block;
text-decoration: none;
margin: 1px;
height: 100%;
width: 100%;
background: url(../../../img/tabs.png) center no-repeat;
/*
&.home {
background: url(../../../img/tabs.png) top left no-repeat;
}
&.profile {
background: url(../../../img/tabs.png) top left no-repeat;
}
&.cam {
background: url(../../../img/tabs.png) top left no-repeat;
}*/ }
footer ul li a.current {
margin-top: 5%;
height: 80%;
width: 80%;
background-color: #ccc;
text-indent: -9999px;
border-radius: 5px;
-webkit-box-shadow: inset 0 0 50px #666;
-moz-box-shadow: inset 0 0 50px #666;
box-shadow: inset 0 0 50px #666; }
答案 0 :(得分:1)
这是demo fiddle。我做了什么
text-align: center
到ul
,所以这是继承的,一切都集中在line-height
设置与width
相同,因此所有内容都垂直居中display:block
,width: 33.33%
和float:left
- 我还添加了overflow:hidden
a
元素包含width: 100%
和margin: 1px
现在,您可以通过添加图片和/或真实文本来播放它。