2011-09-01 48 views
0

我有一個特定的問題,並通過搜索了很多問題找到解決方案,但我似乎無法解決它。問題如下:定位在IE7稍微偏離(像10px頂部和右側)

頁面上有主要的「wrapper」div(爲了居中理由),裏面有一些文本,圖像和一些包含(頁腳,頁眉等)。圖像使用「position:absolute」,並使用CSS「top」和「left」屬性來抵消它們。然而,Firefox和Internet Explorer 7似乎開始從不同的角度偏移,這意味着大多數圖像在IE7中只有大約10px和10px的多一些。

我已經做了什麼來確保; - 驗證我的HTML與W3C驗證(固定的一切) - 試圖取代位置:絕對;有一些立場:親戚; - 包裝的位置已被設置爲position:relative; - 寧願不想只爲IE7使用特定的樣式表(所以沒有嘗試) - PS:使用meta http-equiv =「X-UA-Compatible」content =「IE = EmulateIE7」讓我的IE8瀏覽器顯示我的項目就像它在IE7

我真的希望你能幫助我!在此先感謝,並在此我給相應的HTML和CSS

HTML:

<?xml version="1.0" encoding="utf-8"?> 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head> 

<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7"/> 

<title> 
Document Title 
</title> 

<link rel='stylesheet' type="text/css" href="includes/mainmenu/Mainmenustyle.css"/> 
<link rel='stylesheet' type="text/css" href="includes/header_main/header_mainstyle.css"/> 
<link rel='stylesheet' type="text/css" href="includes/footer_main/footer_mainstyle.css"/> 
<link rel='stylesheet' type="text/css" href="Homepagestyle.css"/> 

</head> 

<body> 

<div id="bg"></div> 
<div id="wrapper"> 

<div> 
<!--#include virtual="includes/mainmenu/mainmenu.html" --> 
</div> 

<div> 
<!--#include virtual="includes/header_main/header_main.html" --> 
</div> 

<div id="about_us" class="about_us"> 
<p>Some text.</p></div> 

<a href="portfolio/graphic/fotoanne.shtml" class="rollover" title="FotoAnne"><span class="displace"></span></a> 

<div id="aboutgreyhorsenl_title" class="aboutgreyhorsenl_title"> 
<img src="images/aboutnl_image.png" alt="About Greyhorse"/></div> 


<div> 
<!--#include virtual="includes/footer_main/footer_main.html" --> 
</div> 

</div> 
</body> 
</html> 

CSS:

#wrapper{ 
position:relative; 
z-index: 1; 
margin:10px auto; 
width:1100px; 
} 

#bg { 
    width: 100%; 
    height: 614px; 
    position: absolute; 
    top: 93px; 
    left: 0; 
    background-image: url(images/stripe.png); 
    background-repeat: repeat-x repeat-y; 
    background-attachment: scroll; 
} 

body { 
background-image:url(images/Background_Homepage.png); 
background-attachment: scroll; 
background-repeat: repeat-x; 
background-position: top; 
font-family: arial; 
color: #111111; 
font-size: 0.75em; /* 12px/16=0.75 em */ 
word-spacing: 2px; 
line-height: 175%; 
} 

.about_us { 
display: block; 
width: 420px; 
height: 12px; 
position: absolute; 
left:290px; 
top:-110px; 
} 

.aboutgreyhorsenl_title { 
position: absolute; 
top: 280px; 
left: 400px; 
} 

a.rollover { 
display: block; 
width: 155px; 
height: 115px; 
text-decoration: none; 
background: url("images/FotoAnne_thumbnail.png"); 
position: absolute; 
left:735px; 
top:-100px; 
} 

a.rollover:hover { 
background-position: 775px 0; 
} 

.displace { 
position: absolute; 
left:287px; 
top:-205px; 
} 

在此先感謝再次的人誰可以幫助我!

+0

我試圖刪除一些由一個要素之一,看看這樣做的時候有任何變化。刪除包含(沒有效果)的包裝(沒有效果)比div id =「bg」用於第二個BG(沒有效果),並最終刪除.body屬性,但這也沒有做任何改變。大多數圖像仍然有點(像10,15px)off – Kiwi1

+0

由於XML-Prolog('<?xml ...'),您的文檔在IE7中處於怪異模式。如果您將其移除並在標準模式下工作,它會有幫助嗎? – RoToRa

+0

哦,我甚至沒有注意到我還有XML-Prolog,謝謝你。即使如此,當我刪除它,但很遺憾沒有解決我的問題... – Kiwi1

回答

0

html5boilerplate中的style.css文件將使所有瀏覽器具有相同的「默認」設置。將此css文件添加到您的網站(作爲第一個被加載的網站)可能會解決此問題。

http://html5boilerplate.com/

+0

謝謝你的回答。我試過你的解決方案,但不幸的是它不工作。我瀏覽了網站,發現他們正在使用名爲NORMALIZE.CSS的.css文件來保留有用的瀏覽器默認設置。也許我應該嘗試那個? – Kiwi1

+0

嗯,還沒有嘗試正常化,但你可以試試它.. –