<分区>
<分区>
我在 Firefox 中遇到 DIV 垂直对齐问题
HTML代码是:
<div class="mess"><div class="rpl"><img src="img/16.png" width="16" height="16" border="0"></div><div class="pic"><img src="img/1.png" width="100" height="100" border="0"></div></div>
CSS 看起来像:
.mess{ float:left; width:658px; border-top:1px solid #CCC;padding-top:5px; }
.rpl{ position: relative;width:19px; float:left;top: 20%;display: table-cell; vertical- align: middle; padding-top:20px; }
.pic{width:100px; float:left; padding-bottom:5px;margin-right:10px; }
我试图将“rpl”DIV 放在“mess”DIV 的垂直中间。 在 IE 中它看起来不错,但我无法在 Firefox 中正确使用它(总是在“困惑”div 的顶部)
我尝试使用 display: inline,display: table-cell for "rpl"DIV 但在 FF 中没有效果。
FF中DIV垂直对齐有什么解决办法吗?
最佳答案
要垂直对齐一个 div,您需要执行几个步骤
说明:将 margin-top 和 bottom 设置为 auto 会将边距平均分配给顶部和底部。 line-height 和 height 相同时,它显示为垂直对齐。
希望对你有帮助
关于html - Can't find for CSS vertical align for Firefox 的解决方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2533842/