2014-10-19 152 views
2

我一直在爲我當前的Web開發類中期網站工作,並遇到一個問題,我一直沒能找到解決方案。 IE11(可能更早的版本)似乎不喜歡我的佈局,我不知道爲什麼。在Firefox和Chrome中一切都很好。這是鏈接:http://auharvey.com/1510/midterm/index.htmlCSS佈局完全搞砸了IE 11

任何幫助將不勝感激!

#wrapper { 
 
\t width: 800px; 
 
\t margin-left: auto; 
 
\t margin-right: auto; 
 
\t background-color: #855321; 
 

 
\t } 
 
\t 
 
body { 
 
\t background-color: #e6c6a6; 
 
\t font-family: calibri, sans-serif; 
 
\t } 
 

 
header, nav, main, footer { 
 
\t display: block; 
 
\t } \t 
 
\t 
 
/* a:link { 
 
\t color: #855321; 
 
\t } 
 
\t 
 
a:hover { 
 
\t color: #4c9860; 
 
\t } 
 
\t 
 
a:visited { 
 
\t color: #855321; 
 
\t } 
 
\t */ 
 
header { 
 
\t background-color: #cc9966; 
 
\t border: 3px solid #855321; 
 
\t margin: 0; 
 
\t padding: 0 10px; 
 
\t 
 
\t } 
 
\t 
 
nav { 
 
\t margin: 0; 
 
\t padding: 0; 
 
\t height: 24px; 
 
\t border: 3px solid #855321; 
 
\t 
 
\t } 
 

 
nav ul { 
 
\t list-style-type: none; 
 
\t 
 
\t padding: 0; 
 

 
\t margin: 0; 
 
\t } 
 
\t \t 
 
nav li { 
 
\t display: inline; 
 
\t margin: 0; 
 
\t padding: 0; 
 
\t } 
 
\t 
 
nav a { 
 
\t display:inline-block; 
 
\t width: 262px; 
 
\t height: 24px; 
 
\t background-color: #cc9966; 
 
\t color: #855321; 
 
\t text-align: center; 
 
\t text-decoration: none; 
 
\t text-transform: uppercase; 
 
\t line-height: 24px; 
 
\t font-weight: bold; 
 
\t margin: 0; 
 
\t padding: 0; 
 
\t } 
 
\t 
 
nav a:hover { 
 
\t background-color: #4c9860; 
 
\t color: #855321; 
 
\t } 
 
\t 
 
nav a:visited { 
 
\t color: #855321; 
 
\t } 
 
\t 
 
#container { 
 
\t width: 800px; 
 
\t background-color: #ff0000; 
 
\t } 
 
\t 
 
main { 
 
\t display: block; 
 
\t min-height: 290px; 
 
\t background-color: #cc9966; 
 
\t border: 3px solid #855321; 
 
\t margin: 0; 
 
\t padding: 0 10px; 
 
\t } 
 
\t 
 
#main-right { 
 
\t float: right; 
 
\t width: 374px; 
 
\t min-height: 290px; 
 
\t background-color: #cc9966; 
 
\t border: 3px solid #855321; 
 
\t margin: 0; 
 
\t padding: 0 10px; 
 
\t } 
 

 
.highlight { 
 
\t background-color: #4c9860; 
 
\t font-weight: bold; 
 
\t font-style: italic; 
 
\t } 
 

 
.float-left { 
 
\t float: left; 
 
\t width: 374px; 
 
\t } 
 
\t 
 
.float-right { 
 
\t float: right; 
 
\t padding: 0; 
 
\t margin: 10px 5px 10px 10px; 
 
\t } 
 
\t 
 
ul { 
 
\t list-style-type: square; 
 
\t line-height: 150%; 
 
\t } 
 
\t 
 
footer { 
 
\t clear: both; 
 
\t background-color: #cc9966; 
 
\t border: 3px solid #855321; 
 
\t font-size: small; 
 
\t text-align: center; 
 
\t margin: 0; 
 
\t padding: 0; 
 
\t }
<!DOCTYPE html> 
 
<html lang="en"> 
 
<head> 
 
<title>Enoch Treadwell's Trash Service</title> 
 
<meta charset="utf-8"> 
 
<link rel="stylesheet" href="styles.css"> 
 
<!--[if lt IE 9]> 
 
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"> 
 
</script> 
 
<![endif]--> 
 
</head> 
 
<body> 
 
<div id="wrapper"> 
 
\t <header role="banner"> 
 
\t \t <h1>Enoch Treadwell's Trash Service</h1> 
 
\t </header> 
 
\t <nav role="navigation"> 
 
\t \t <ul> 
 
\t \t \t <li><a href="index.html">Home</a></li> 
 
\t \t \t <li><a href="services.html">Services</a></li> 
 
\t \t \t <li><a href="contact.html">Contact</a></li> 
 
\t \t </ul> 
 
\t </nav> 
 
\t <div id="container"> 
 
\t \t <main role="main" class="float-left"> 
 
\t \t \t <h3>Who We Are</h3> 
 
\t \t \t <p>Enoch Treadwell's Trash Service is the new option in your town for all your trash disposal needs! Weather your looking for a weekly trash pick up or just a one time pick up by appointment we are the best choice! We offer great rates on all our trash disposal services! We even have a special offer for year contracts for weekly pick-up service at the low price of 15.99 a month! Please visit our convenient location at blah blah blah or give us a call at (999) 555-1234 between the hours of 8 to 5 M-F or 10 to 2 on Saturday.<p> 
 
\t \t </main> 
 
\t \t 
 
\t \t <div id="main-right"> 
 
\t \t <img src="special2.png" class="float-right" width="100" alt="Specials"> 
 
\t \t \t <h3>Specials</h3> 
 
\t \t \t 
 
\t \t \t <ul> 
 
\t \t \t \t <li><span class="highlight">10% OFF</span> Dumpster Rental for bulk</li> 
 
\t \t \t \t <li><span class="highlight">$15.99 </span> a month for Weekly Pick-Up with a one year contact.</li> 
 
\t \t \t \t <li><span class="highlight">20% OFF</span> Pre-Sorted Recyclables</li> 
 
\t \t \t \t <li>Discounted rates for Monday pick-ups.</li> 
 
\t \t \t </ul> 
 
\t \t \t 
 
\t \t </div> 
 
\t </div> 
 
\t <footer role="contentinfo"> 
 
\t \t <a href="index.html">Home</a> &#124; <a href="services.html">Services</a> &#124; <a href="contact.html">Contact</a><br> 
 
\t \t Copyright &copy; 2014 Alyssa Harvey<br> 
 
\t \t <a href="mailto:[email protected]">[email protected]</a> 
 
\t </footer> 
 
</div> 
 
</body> 
 
</html>

回答

2

更換主用下面的代碼。似乎你缺少結束p標記

<main role="main" class="float-left"> 
      <h3>Who We Are</h3> 
      <p>Enoch Treadwell's Trash Service is the new option in your town for all your trash disposal needs! Weather your looking for a weekly trash pick up or just a one time pick up by appointment we are the best choice! We offer great rates on all our trash disposal services! We even have a special offer for year contracts for weekly pick-up service at the low price of 15.99 a month! Please visit our convenient location at blah blah blah or give us a call at (999) 555-1234 between the hours of 8 to 5 M-F or 10 to 2 on Saturday.</p> 
     </main> 
+0

哇感謝這麼多。我很驚訝它通過了W3C驗證!下次我會確保自己檢查一遍,即使它通過了驗證。 – Alyssa 2014-10-19 14:49:53

+0

好,請接受答案。謝謝 – 2014-10-19 14:50:32

0

嗯,我無法評論,因爲我沒有我的50和聲譽,但這裏是一個額外的小費:

不要用戶像素(PX)所以你的網站對於寬度/高度更小的顯示器來說是靈活的。

在CSS定義在你的身體{}:

body{ 
    width: 100%; 
    font-size: 100%; 
    } 

和其他類/ IDS使用的字體大小此:

#example{ 
    font-size: 1em; 
    } 

這裏是EM等於正常字體大小在body {}中定義。

1 em =正常字體大小。

2 EM =字體大小* 2 ...

http://www.w3.org/Style/Examples/007/units.en.html