我有这段代码,它在 firefox 和 chrome 中的表现不同。
<h2>Presenting
<span style="font-weight:bold">Analytics by </span>
<div class="fi_logo"><img src="IMAGEURL" /></div>
</h2>
上面引用的类 fi_logo 是:
.fi_logo {
min-width: 35px;
height: 35px;
margin-left: 40px;
position: absolute;
top:-5px;
left: 262px;
float:right;
}
在firefox 中,由于fi_logo 中的margin-left 在图像和文本(h2 中)之间存在偏移。如果我不添加左边距,则图像会与 chrome 中的文本重叠。
所以,简而言之,如果我添加 margin-left 属性,它在 chrome 中有效,而在 firefox 中会导致较大的偏移。关于如何解决这个问题有什么建议吗?
最佳答案
这是:http://jsfiddle.net/bikerabhinav/mpL79/2/ 使用相对位置和绝对位置的组合。 另外,不要在 h2 中使用 div - 错误的标记
关于css - 为什么我的图像在 Firefox 和 Chrome 中太左对齐,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7618652/