我遇到了一个问题,就是下面的布局在所有浏览器中都无法显示相同的效果:
问题在于当
.wrapper {
margin-top: 100px;
position: relative;
height: 400px;
width: 400px;
border: 1px solid black;
}
.icon {
position: absolute;
width: 40;
height: 40px;
border: 1px solid black;
background-color: white;
top: -20px;
right: 10px;
}
<fieldset class="wrapper">
<legend>Legendary!</legend>
<div class="icon">icon</div>
</fieldset>
legend
元素存在时,在Firefox上,div.icon
会向下拉动几个像素,在Chrome上则会向上拉动几个像素。当我移除legend
元素时,一切都正常了,但我不能这么做。有什么办法使它在所有浏览器中看起来都一样吗?