作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我需要一点帮助:)
我有这样的布局:http://jsfiddle.net/eyTYF/
只是一个 ul
和 5 个 li
,里面都有 a
标签。
我希望所有这些元素都占满屏幕宽度的 100%,图标保持其大小 (50px),仅标题区分大小。
我该怎么做?
提前谢谢你:)
最佳答案
使用 display: table
很容易做到这一点。 http://codepen.io/pageaffairs/pen/lbBKx
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<style media="all">
ul {list-style: none; padding-left: 0; width: 100%; display: table;}
li {display: table-cell;}
li:nth-child(1), li:nth-child(2), li:nth-child(4), li:nth-child(5){
width: 50px;
}
li{line-height: 50px;text-align: center;}
li:nth-child(1){
background: red;
}
li:nth-child(2){
background: green;
}
li:nth-child(3){
background: blue;
}
li:nth-child(4){
background: green;
}
li:nth-child(5){
background: red;
}
a{color: white; display: block; width: 100%;vertical-align: middle;line-height: 50px;}
</style>
</head>
<body>
<ul>
<li><a href="#"><i>Icon 1</i></a></li>
<li><a href="#"><i>Icon 2</i></a></li>
<li><a href="#"><span>Title</span></a></li>
<li><a href="#"><i>Icon 3</i></a></li>
<li><a href="#"><i>Icon 4</i></a></li>
</ul>
</body>
</html>
关于html - 响应式设计 : centering a title inside an li with 2 other li's each side,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16816664/
我是一名优秀的程序员,十分优秀!