gpt4 book ai didi

html - 响应式设计 : centering a title inside an li with 2 other li's each side

转载 作者:行者123 更新时间:2023-11-28 18:21:01 24 4
gpt4 key购买 nike

我需要一点帮助:)

我有这样的布局: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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com