我正在制作一个具有自适应设计的网站,以便它看起来不错,并且在不同的设备上调整好。页面大小调整时页眉正在移动
除了h1文本,它一切正常。我有一个固定宽度为800px的容器,在适当的屏幕尺寸下变为100%的宽度。标题文本居中,但是,当屏幕大小改变并且容器变为100%宽度时,标题现在偏离中心,稍微向右移动。
这里是我的HTML:
<html>
<head>
<link rel="stylesheet" type="text/css" href="styles.css">
<title>Home</title>
</head>
<body>
<div id="container">
<h1>My Website!</h1>
</div>
</body>
</html>
我的CSS:
* {
font-family: Helvetica Neue;
}
body {
background-color: gray;
margin: 0;
}
h1 {
text-align: center;
}
#container {
width: 800px;
margin: 0 auto;
padding: 20px;
background-color: white;
}
/* Resizability (Responsive Web Design) */
@media screen and (max-width: 840px) {
#container {
width: 100%;
}
}
到底哪里出问题了?