[英]Simple vertical align issue with div
我的腦子很油炸,所以我需要你幫忙。
我試圖在div中進行垂直對齊。
我有
HTML
<a href='#'>
<div class="div">
<div class="insideDiv">text here</div>
</div>
</a>
我的css
a {
color: #006699;
text-decoration: none;
font-size: 10pt;
border-width: 0;
position: relative
}
.div{
position: absolute;
background-color: red;
top: -75px;
left: 50px;
width: 100px;
height: 50px;
z-index: 1000;
padding: 8px;
}
.insideDiv{
background-color: white;
width: 100px;
height: 47px;
border: solid 1px grey;
font-weight: bold;
vertical-align: middle;
text-align: center;
}
看起來text here
不能垂直對齊到中間,而是水平對齊到中心。 任何人都可以幫我解決這個問題嗎? 非常感謝!
vertical-align
屬性不適用於塊級元素,僅適用於內聯格式化上下文和表格單元格中的元素
你可以添加display: table-cell;
到你的.insideDiv
類垂直居中它的文字:
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.