要求,a大小填充占整个div1,a中文字上下左右居中,a中文字多少不确定?不知如何解决?hehehehehh.div1{width:300px;height:80px;}.div1a{}
2 回答

HUX布斯
TA贡献1876条经验 获得超6个赞
.div1{width:300px;height:80px;background:#eee;position:relative;text-align:center;display:table;}.div1a{display:table-cell;vertical-align:middle;}注意兼容性,推荐直接用table标签写

慕容708150
TA贡献1831条经验 获得超4个赞
translate-50%.div1{width:300px;height:400px;background-color:#eee;position:relative}.div1a{position:absolute;top:50%;left:50%;transform:translate3d(-50%,-50%,0)}
添加回答
举报
0/150
提交
取消