你好,我想把這個跨度標簽排成一行
但是有內部文本的標簽被排序,沒有內部文本的標簽
文本排序
所以這些標簽高度不正確
我想在一行中對這個跨度框(class==a)進行排序
解決辦法是什么?
示例代碼在底部
<html>
<head>
<title>a</title>
<meta charset = "utf-8">
<style>
.a {
width: 17%;
height: 5%;
display: inline-block;
}
</style>
</head>
<body>
<span class = "a"></span>
<span class = "a">2</span>
<span class = "a">2</span>
<span class = "a">2</span>
<span class = "a">2</span>
</body>
</html>
uj5u.com熱心網友回復:
1.) 如果height使用百分比值定義,則父元素需要定義高度。下面我為body(直接父級)和html的父級定義了 100% 高度body。如果這是在 a 內div,則div需要一個高度定義。
2.) 要通過其頂部邊框對齊行內塊,您可以使用vertical-align: top;(默認為baseline否則)
html,
body {
height: 100%;
min-height: 600px;
}
.a {
width: 17%;
height: 5%;
display: inline-block;
border: 1px solid red;
vertical-align: top;
}
<body>
<span class="a"></span>
<span class="a">2</span>
<span class="a">2</span>
<span class="a">2</span>
<span class="a">2</span>
</body>
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/346566.html
上一篇:如何在媒體查詢中使用邏輯運算式?
