要求,a大小填充占整个div1,a中文字上下左右居中,a中文字多少不确定?
不知如何解决?
<div class="div1">
<a herf="xxxx">hehehehehh</a>
</div>
.div1{
width:300px;
height:80px;
}
.div1 a{
}
translate -50%
.div1{
width: 300px;
height: 400px;
background-color: #eee;
position: relative
}
.div1 a{
position: absolute;
top: 50%;
left: 50%;
transform: translate3d(-50%, -50%, 0)
}
.div1{ width:300px;height:80px; background:#eee; position:relative; text-align: center;display:table; }
.div1 a{ display:table-cell; vertical-align:middle; }
注意兼容性,推荐直接用 table 标签写