高度不一的<li>列表靠底部对齐

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>测试文字底部对齐</title>
<style type="text/css">
* {
margin: 0;
padding: 0;
}

body {
font: 12px/1.5 arial;
}

ul {
list-style: none;
}

ul li {
display: inline-block;
*display: inline;
*zoom: 1;
width: 1em;
margin-right: 10px;
overflow: hidden;
background: #cecece;
}
</style>
</head>

<body>
<ul>
<li style="height: 65px;">65</li>
<li style="height: 80px;">80</li>
<li style="height: 40px;">40</li>
<li style="height: 60px;">60</li>
<li style="height: 50px;">50</li>
<li style="height: 70px;">70</li>
</ul>
</body>

</html>

预览1.png
预览2.png

  • <li>标签内没有文本节点时,通过设置样式**display:inline-block**可以将高度不一样的<li>标签底部对齐。
  • <li>标签内有文本节点时,通过设置样式**display:inline-blockoverflow:hidden**可以将高度不一样的<li>标签底部对齐。

高度不一的&lt;li&gt;列表靠底部对齐
https://tedding.dev/2017/09/11/15e704ae0c8.html
作者
TED.DING
发布于
2017年9月11日
许可协议