【发布时间】:2013-03-08 22:18:10
【问题描述】:
与 Chome 和 IE 相比,我不明白为什么在 Firefox 中的不同位置显示 HTML 元素。我正在使用 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:absolute;左:0;对:0; margin:0 auto;} 并让浏览器计算中心位置。
-
不,我不想居中 - 我想将文本向右对齐到与背景图像相关的特定位置,但遗憾的是我无法向您展示。
标签: css google-chrome firefox