我不知道为什么我要在Firefox中的不同位置显示HTML元素,而不是Chome和IE。我正在使用position:absolute将标题和副标题文本放置在标题中,但我希望它们是标题,但FF和Chrome/IE之间的文本元素的水平位置似乎差不多有30px差距Firefox和Chrome/IE之间的显示区别
该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 老实说,我不明白是什么差别是如此之大p将不胜感激。
我没有看到任何区别。清除缓存? – slamborne 2013-03-20 00:47:22
您是否想要标题和副标题?你可以用{position:absolute;左:0;右:0; margin:0 auto;}并让浏览器计算中心位置。 – eivers88 2013-03-20 00:47:35
不,我不想中心 - 我试图将文本对齐到与特定位置相关的背景图像,我不幸无法向您展示。 – user2188805 2013-03-20 01:04:06