我知道这个问题之前已经在这个论坛上被提出过,但没有一个答案有帮助,所以我在这里再问一遍,我的html5和css网站有一个包装器(大多数都是这样),但它没有调整大小通过内容,我已经检查了一些我认为可能出错的内容,这里是所有想要查看内容的人的代码,谢谢!
HTML
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Home</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div id="wrapper">
<div id="header">
<ul>
<a href="index.html"><li>Home</li></a>
<li> | </li>
<a href="blog.html"><li>Blog</li></a>
<li> | </li>
<a href="videos.html"><li>Videos</li></a>
<li> | </li>
<a href="#"><li>Contact-Me</li></a>
</ul>
<h1>Zormion's Blog</h1>
</div>
<div id="content">
<h2>Latest Blog Post:</h2>
</div>
<div id="sidebar">
<h3>Tweets:</h3>
<a class="twitter-timeline" href="https://twitter.com/Zormion" data-widget-id="537398875540455424">Tweets by @Zormion</a>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+"://platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
</div>
</div>
</body>
</html>
CSS
* {
margin: 0;
padding: 0;
}
body {
background-color: #DFC1B0
}
#wrapper {
margin: 20px auto;
width: 1000px;
text-align: left;
background-color: #CCCCCC;
}
#header {
width: 100%;
height: 40px;
background-color: #000;
}
#header h1 {
margin-left: 10px;
color: white;
}
#header ul {
padding-top: 10px;
float: right;
margin-right: 20px;
}
#header ul li {
display: inline-block;
list-style: none;
color: #fff;
font-size: 16px;
}
#content {
width: 63%;
height: 150px;
background-color: grey;
float: left;
margin: 10px;
padding: 20px;
}
#content h2 {
text-align: center;
font-size: 32px;
}
#sidebar {
width: 25%;
float: left;
background-color: grey;
margin: 10px;
padding: 20px;
border: 1px black;
}
#sidebar h3 {
text-align: center;
color: black;
font-size: 32px;
margin-bottom: 10px;
margin-top: -10px;
}
.twitter-timeline {
height: 500px;
}
答案 0 :(得分:1)
像这样使用:
#wrapper {
margin: 20px auto;
width: 100%;
max-width: 1000px;
text-align: left;
background-color: #CCCCCC;
}