1.新增如下結構
2.在css資料夾裡新增下面兩個檔案
3.編輯index.html
<!DOCTYPE html>
<html lang="zh-Hant-TW">
<head>
<meta charset="UTF-8">
<title>Test</title>
</head>
<body>
</body>
</html>
效果
4.編輯index.html
<!DOCTYPE html>
<html lang="zh-Hant-TW">
<head>
<meta charset="UTF-8">
<title>Test</title>
<link rel="stylesheet" href="css/reset.css">
<link rel="stylesheet" href="css/style.css">
</head>
<body>
<header class="header">
</header>
<div class="wrapper">
<main class="main">
</main>
<div class="sidemenu">
</div>
</div>
<footer class="footer">
</footer>
</body>
</html>
5. index.html
<!DOCTYPE html>
<html lang="zh-Hant-TW">
<head>
<meta charset="UTF-8">
<title>Test</title>
<link rel="stylesheet" href="css/reset.css">
<link rel="stylesheet" href="css/style.css">
</head>
<body>
<header class="header">
</header>
<div class="wrapper clearfix">
<main class="main">
</main>
<div class="sidemenu">
</div>
</div>
<footer class="footer">
</footer>
</body>
</html>
6. style.css
.header{
width: 100%;
}
.wrapper{
width: 970px;
margin: 30px auto 40px;
}
.main{
display: block;
float: left;
width: 660px;
}
.sidemenu{
float: right;
width: 275px;
}
.footer{
width: 100%;
}
.header, .main, .sidemenu, .footer{
border: 1px solid #aaa;
background-color:#ccc;
}
.header, .footer{
height: 100px;
}
.main, .sidemenu{
height: 500px;
}
.clearfix::after{
content: '';
display: block;
clear: both;
background-color:lightgreen;
}
=============
注意:
.clearfix::after{
content: ''; <---''是兩個單引號而非一個"雙引號
display: block;
clear: both;
background-color:lightgreen;
}
=============
沒有留言:
張貼留言