[英]Negative top margin in Firefox moves elements to the right
當我在父元素中應用-3px的負邊距頂部時,所有子元素都向右移動(在Firefox和IE8中),但在Chrome瀏覽器中看起來很好(元素居中)。
是什么原因造成的?
<div class="menu-tab">
<div class="folder-tab">
<span class="normal-small-text">Ingresar<i class="icon-chevron-down icon-white"></i></span>
</div>
</div>
上邊距應用於類.menu-tab
這是在Chrome中
和Firefox
由於這似乎已為您解決了該問題,因此我將其作為答案。
更換:
margin-top: -3px;
與:
position: relative;
top: -3px;
那么,請嘗試將父元素中的邊距定義為0
.menu-tab {margin:0;}
然后根據需要為子元素定義邊距。
嗯,我看不出在該元素上使用margin-top
任何原因,您可以輕松地將其高度設置為容器的高度(以line-height
並且它應該自動居中,以及text-align:center
to center容器內的文本,它將自動在容器內垂直和水平居中放置文本。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.