看到这个CSS:垂直中心内容补充:后和“内容”属性
div {
width: 100px;
height: 100px;
background: #333;
color: #fff;
}
div:after {
content: "test";
height: 100px;
}
我想要垂直居中的div:after
内容。我怎样才能做到这一点?
我无法设置line-height
到px
值作为div
的高度可能是动态的(height: 100px
只是在这个例子中,在我的应用程序是根据它延伸的内容)
http://codepen.io/anon/pen/ELnsJ
我喜欢这个解决方案,因为它不包括任何布局改变为'显示:table'确实 – simPod