CSS布局在IE 11中完全搞砸了

时间:2014-10-19 14:35:31

标签: html css layout internet-explorer-11

我一直在为我当前的Web开发课程的中期站点工作,并遇到了一个我无法找到解决方案的问题。 IE11(可能还有早期版本)似乎不喜欢我的布局,我不知道为什么。在Firefox和Chrome中,一切都很好。这是链接:http://auharvey.com/1510/midterm/index.html

非常感谢任何帮助!

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

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

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

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

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

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

.float-left {
	float: left;
	width: 374px;
	}
	
.float-right {
	float: right;
	padding: 0;
	margin: 10px 5px 10px 10px;
	}
	
ul {
	list-style-type: square;
	line-height: 150%;
	}
	
footer {
	clear: both;
	background-color: #cc9966;
	border: 3px solid #855321;
	font-size: small;
	text-align: center;
	margin: 0;
	padding: 0;
	}
<!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">
	<header role="banner">
		<h1>Enoch Treadwell's Trash Service</h1>
	</header>
	<nav role="navigation">
		<ul>
			<li><a href="index.html">Home</a></li>
			<li><a href="services.html">Services</a></li>
			<li><a href="contact.html">Contact</a></li>
		</ul>
	</nav>
	<div id="container">
		<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>
		
		<div id="main-right">
		<img src="special2.png" class="float-right" width="100" alt="Specials">
			<h3>Specials</h3>
			
			<ul>
				<li><span class="highlight">10% OFF</span> Dumpster Rental for bulk</li>
				<li><span class="highlight">$15.99 </span> a month for Weekly Pick-Up with a one year contact.</li>
				<li><span class="highlight">20% OFF</span> Pre-Sorted Recyclables</li>
				<li>Discounted rates for Monday pick-ups.</li>
			</ul>
			
		</div>
	</div>
	<footer role="contentinfo">
		<a href="index.html">Home</a> &#124; <a href="services.html">Services</a> &#124; <a href="contact.html">Contact</a><br>
		Copyright &copy; 2014 Alyssa Harvey<br>
		<a href="mailto:aharvey3869@student.gwinnetttech.edu">aharvey3869@student.gwinnetttech.edu</a>
	</footer>
</div>
</body>
</html>

2 个答案:

答案 0 :(得分:2)

使用以下代码替换main。好像你错过了一个结束标签

<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>

答案 1 :(得分:0)

好吧,我无法评论,因为我没有50个声誉,但这里还有一个额外提示:

不要使用Pixel(px),因此您的网站可以灵活地用于宽度/高度更小的显示器。

在css中定义你的身体{}:

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

并在其他类/ ids中使用字体大小:

    #example{
    font-size: 1em;
    }

这里的em等于body {}中定义的普通font-size。

1 em =正常字体大小。

2 em = font-size * 2 ...

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