css - 为什么我的图像在 Firefox 和 Chrome 中太左对齐

标签 css firefox google-chrome html image

我有这段代码,它在 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/

相关文章:

css - Firefox 设置了错误的插入符号位置 contentEditable with :before

css - 为什么行距不一样?

jquery - 为什么我的 jquery 内容 slider 不工作?

html - 动态定位CSS工具提示

html - 将 css 应用于元素 "path"

android - 伪元素:after disapears on chrome mobile

jquery - 为什么 jQuery 的 position() 和 offset() 方法在 Chrome 中返回小数?

css - grunt-cssc 不工作 "cannot read property ' 类型'"~ Foundation 5

最新行的 MySQL 代码仅适用于 Chrome,不适用于 Firefox

javascript - 使用 Canvas 绘制包含 SVG 源的 img 以获取数据 URL