在同一文件夹中
我的索引是:
<html>
<head>
<meta charset="utf-8"
<link href="style.css" rel="stylesheet" />
<title>collapaing Header</title>
</head>
<body>
<div id="container">
<header>
<h1>This is my header </h1>
</header>
<div id="banner">
<h2> This is the banner </h2>
</div>
<div id="content">
<p>Content goes here </p>
</div>
</body>
</html>
我的css是:
body{
text-align: center;
}
header{
height: 100px;
background: #dbdbdb;
width: 100%;
z-index: 10;
}
.banner{
width: 100%;
height: 500px;
position: fixed;
top: 100px;
background: #707070;
}
.content{
width: 100%;
position: relative;
top: 400px;
height: 1500px;
}
- 当我测试的时候,你的CSS正在工作
- 您的元标记需要结束
/>
,现在它没有正确关闭 - 2号应该可以解决您的问题,如果没有,请确保
style.css
和index.php
在同一目录中
首先关闭meta标签,和尝试不自行关闭链接标签,检查css文件是否与html文件