css - Firefox 和 Chrome/IE 之间的显示差异

标签 css google-chrome firefox

与 Chome 和 IE 相比,我无法理解为什么 HTML 元素在 Firefox 中显示在不同的位置。我正在使用 position:absolute 将标题和副标题文本放在我希望它们所在的标题中,但 FF 和 Chrome/IE 之间文本元素的水平位置似乎有大约 30px 的差异

HTML 很简单,看起来像这样:

<div id="mainPage">
<div id="mainContent" class="mainRounded">
    <div id="header">
        <div id="title"><h1>Longer Title Text</h1></div>
        <div id="subtitle"><h2>Subtitle text</h2></div>
        <div id="banner"></div>
    </div>
</div>
</div>

CSS 是这样的:

.mainRounded {
margin: 0 auto;
width: 1000px;
border-radius: 30px;
background-color:#e9d7dc;
box-shadow: 5px 5px 3px #888888;
overflow:hidden;
margin-bottom: 25px;
}
#header #banner {
background-color: #0033CC;
height: 150px;
opacity:0.4;
filter:alpha(opacity=40); /* For IE8 and earlier */
position: relative;
overflow:hidden;
border-radius: 30px 30px 0 0;
}
#header #title {
padding: 0 ;
position: absolute;
top: -40px;
left: 710px;
}
#header #subtitle {
padding: 0 ;
position: absolute;
top: 95px;
left: 870px;
}
#header #title h1 {
font-family: Georgia;
    font-size: 54px;
    font-style: italic;
    font-weight: normal;
text-shadow: 2px 2px 5px #0033CC;
}
#header #subtitle h2 {
font-family: Georgia;
    font-size: 26px;
    font-style: italic;
    font-weight: normal;
}

您可以在此处的测试页面上原地查看:http://mardona.org/test.php 老实说,我不明白有什么区别,所以我们将不胜感激。

最佳答案

你应该把position: relative;赋给.mainRounded,然后在margin-top的其他positioned值中将top的margin值改成0,那么它必须随心所欲地工作。

关于css - Firefox 和 Chrome/IE 之间的显示差异,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15513075/

相关文章:

html - Firefox 中表格中的多余空格

html - 文本区域内的按钮与文本重叠

html - 在 Bootstrap 中滚动时修复侧边栏

javascript - 在网站上可视化图表

google-chrome - 从另一台机器进行 Chrome 远程调试

javascript - &lt;input type ="file"/> 文件格式验证在 chrome 和 IE 中不起作用

jquery 插件 'blockUI' 在 Firefox 中不会使屏幕变灰

html - 是否可以将 HTML 属性应用于 CSS 中的 Div 标签?

html - 如何使用 CSS 将 div 样式化为三 Angular 形?

javascript - 使用 Protractor 在 Firefox 上下载文件