CSS的vertical-align或vlalign的CSS3等效属性是什么?如果我们需要在不同的浏览器中实现它,例如Chrome或Mozilla,该怎么办?我们是否需要在该特定属性之前使用-moz或-webkit作为不同浏览器支持的前缀?
答案 0 :(得分:0)
解决方案1:
在你的包含div上试试这个:
div {
display: table-cell;
vertical-align: middle;
}
解决方案2:
或者,另一个选项是将元素上的CSS设置为:
position: absolute;
top: 0;
bottom: 0;
margin: auto;
height: 50px; //you need to set a fixed height, otherwise it will stretch
当然,您的容器上需要position: relative;
。
两种解决方案都会产生垂直居中的内容。