1. 程式人生 > >html5 css練習 定位布局

html5 css練習 定位布局

absolute bsp height right mar abs 練習 style rgb

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>浮動布局</title>
<link rel="stylesheet" type="text/css" href="st1.css">
</head>
<body>
<header>頭部內容</header>
<aside>側欄導航</aside>
<section>主體內容</section>
<footer>底部</footer>
</body>
</html>

/*定位布局*/
*{
margin: 0;
padding: 0;
}
body{
width: 960px;
margin: 0 auto;
position: relative;
}
header{
width: 960px;
height: 150px;
background: rgba(0,0,0,0.3);

}
aside{
width: 200px;
height: 500px;
background: rgba(200,20,20,0.8);

}
section{
width: 760px;
height: 500px;
background: rgba(20,200,20,0.8);
position: absolute;
right: 0;
top: 150px;
}
footer{
width: 960px;
height: 150px;
background: rgba(60,60,60,0.6);
}

html5 css練習 定位布局