3.4.5 CSS盒子模型——外边距合并
第一个文件style.css
/*
body{
margin: 0px;
}
.mg{
background-color: blue;
width: 100px;
height: 100px;
margin-top: 100px;
}
*/
.body{
margin: 0;
}
.container{
margin: 10px;
}
.bd{
border-style: dotted;
}
.pd{
padding: 100px;
}
.content{
background-color: blue;
}
.container1{
margin: 20px;
}
.bd1{
border-style: dotted;
}
.pd1{
padding: 100px;
}
.content1{
background-color: blue;
}
第二个文件 60.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<!--div class="mg">外边距</div-->
<div class="container">
<div class="bd">
<div class="pd">
<div class="content">Hello</div>
</div>
</div>
</div>
<div class="container1">
<div class="bd1">
<div class="pd1">
<div class="content1">Hello</div>
</div>
</div>
</div>
</body>
</html>
3.4.6 CSS盒子模型——盒子模型应用
第一个文件style.css
*{
margin: 0px;
padding: 0px;
}
.top{
width: 100%;
height: 50px;
background-color: black;
}
.top_content{
width:75%;
height: 50px;
margin: 0px auto;
background-color: blue;
}
.body{
margin:20px auto;
width: 75%;
height: 1500px;
background-color: blanchedalmond;
}
.body_img{
width: 100%; /*这里是整体的75% * 100% =75%*/
height: 400px;
background-color: darkorange;
}
.body_content{
width:100%;
height:1100px;
background-color: blueviolet;
}
.body_no{
width: 100%;
height: 50px;
background-color: aqua;
}
.footing{
width: 75%;
height: 400px;
background-color: indigo;
margin: 0px auto;
}
.footing_content{
width: 100%;
height:350px;
background-color: darkgreen;
}
.footing_menu{
width:100%;
height: 50px;
background-color: darkorange;
}
第二个文件 62.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>盒子模型的应用</title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<div class="top">
<div class="top_content"></div>
</div>
<div class="body">
<div class="body_img"></div>
<div class="body_content">
<div class="body_no"></div>
</div>
</div>
<div class="footing">
<div class="footing_content"></div>
<div class="footing_menu"></div>
</div>
</body>
</html>
3.5.1 CSS常用操作——对齐
第一个文件 style.css
*{
margin: 0px;
}
.div{
width: 70%;
height: 1000px;
background-color: red;
margin: 0px auto;/*前一个属性代表上下,,后一个属性代表左右*/
}
第二个文件 63.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>对齐</title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<div class="div">
</div>
</body>
</html>
3.5.2 CSS常用操作——分类
第一个文件 style.css
li{
display: inline;
visibility: hidden;
}
.p1{
width:400px;
line-height: normal;
max-width: 200px;
}
.p2{
width:400px;
line-height: 200%;
}
.p3{
width:400px;
line-height: 50%;
}
p{
cursor:cell;
}
第二个文件 64.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<ul>
<li>Hello</li>
<li>Hello</li>
<li>Hello</li>
<li>Hello</li>
</ul>
<p class="p1">This is my web page. This is my web page. This is my web page.
This is my web page. This is my web page. This is my web page.
This is my web page. This is my web page. This is my web page.
This is my web page. This is my web page. This is my web page.
</p>
<p class="p2">This is my web page. This is my web page. This is my web page.
This is my web page. This is my web page. This is my web page.
This is my web page. This is my web page. This is my web page.
This is my web page. This is my web page. This is my web page.
</p>
<p class="p3">This is my web page. This is my web page. This is my web page.
This is my web page. This is my web page. This is my web page.
This is my web page. This is my web page. This is my web page.
This is my web page. This is my web page. This is my web page.
</p>
<p>hello</p>
</body>
</html>
3.5.3 CSS常用操作——导航栏
第一个文件style.css
ul{
list-style-type: none;
margin:0px;
padding: 0px;
background-color: burlywood;
width: 400px;
text-align:center;
}
a:link , a:visited{
font-weight: bold;
text-decoration: none;
background-color: burlywood;
color: aliceblue;
width: 100px;
text-align: center;
}
a:active, a:hover{
background-color: crimson;
}
li{
display: inline;
padding: 3px;
padding-left: 5px;
padding-right:5px;
}
第二个文件 65.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<ul>
<li><a href="#">导航1</a></li>
<li><a href="#">导航2</a></li>
<li><a href="#">导航3</a></li>
<li><a href="#">导航4</a></li>
</ul>
</body>
</html>
3.5.4 CSS常用操作——图片
第一个文件style.css
body{
margin:10px auto;
width:50%;
height:auto;
background-color: burlywood;
}
.image{
border: 1px solid darkgray;
width: auto;
height: auto;
float: left;
text-align: center;
margin:5px;
}
img{
margin: 5px;
opacity: 1;
cursor: cell;
}
.text{
font-size: 12px;
margin-bottom: 5px;
}
a:hover{
background-color: crimson;
}
第二个文件 66. html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<div class="container">
<div class="image">
<a href="#" target="_self">
<img src="timg.jpg" alt="风景" width="300px" height="300px">
</a>
<div class="text"> 8月份的维多利亚</div>
</div>
<div class="image">
<a href="#" target="_self">
<img src="timg.jpg" alt="风景" width="300px" height="300px">
</a>
<div class="text"> 8月份的维多利亚</div>
</div>
<div class="image">
<a href="#" target="_self">
<img src="timg.jpg" alt="风景" width="300px" height="300px">
</a>
<div class="text"> 8月份的维多利亚</div>
</div>
<div class="image">
<a href="#" target="_self">
<img src="timg.jpg" alt="风景" width="300px" height="300px">
</a>
<div class="text"> 8月份的维多利亚</div>
</div>
<div class="image">
<a href="#" target="_self">
<img src="timg.jpg" alt="风景" width="300px" height="300px">
</a>
<div class="text"> 8月份的维多利亚</div>
</div>
<div class="image">
<a href="#" target="_self">
<img src="timg.jpg" alt="风景" width="300px" height="300px">
</a>
<div class="text"> 8月份的维多利亚</div>
</div>
<div class="image">
<a href="#" target="_self">
<img src="timg.jpg" alt="风景" width="300px" height="300px">
</a>
<div class="text"> 8月份的维多利亚</div>
</div>
<div class="image">
<a href="#" target="_self">
<img src="timg.jpg" alt="风景" width="300px" height="300px">
</a>
<div class="text"> 8月份的维多利亚</div>
</div>
<div class="image">
<a href="#" target="_self">
<img src="timg.jpg" alt="风景" width="300px" height="300px">
</a>
<div class="text"> 8月份的维多利亚</div>
</div>
<div class="image">
<a href="#" target="_self">
<img src="timg.jpg" alt="风景" width="300px" height="300px">
</a>
<div class="text"> 8月份的维多利亚</div>
</div>
<div class="image">
<a href="#" target="_self">
<img src="timg.jpg" alt="风景" width="300px" height="300px">
</a>
<div class="text"> 8月份的维多利亚</div>
</div>
<div class="image">
<a href="#" target="_self">
<img src="timg.jpg" alt="风景" width="300px" height="300px">
</a>
<div class="text"> 8月份的维多利亚</div>
</div>
<div class="image">
<a href="#" target="_self">
<img src="timg.jpg" alt="风景" width="300px" height="300px">
</a>
<div class="text"> 8月份的维多利亚</div>
</div>
<div class="image">
<a href="#" target="_self">
<img src="timg.jpg" alt="风景" width="300px" height="300px">
</a>
<div class="text"> 8月份的维多利亚</div>
</div>
<div class="image">
<a href="#" target="_self">
<img src="timg.jpg" alt="风景" width="300px" height="300px">
</a>
<div class="text"> 8月份的维多利亚</div>
</div>
<div class="image">
<a href="#" target="_self">
<img src="timg.jpg" alt="风景" width="300px" height="300px">
</a>
<div class="text"> 8月份的维多利亚</div>
</div>
<div class="image">
<a href="#" target="_self">
<img src="timg.jpg" alt="风景" width="300px" height="300px">
</a>
<div class="text"> 8月份的维多利亚</div>
</div>
<div class="image">
<a href="#" target="_self">
<img src="timg.jpg" alt="风景" width="300px" height="300px">
</a>
<div class="text"> 8月份的维多利亚</div>
</div>
<div class="image">
<a href="#" target="_self">
<img src="timg.jpg" alt="风景" width="300px" height="300px">
</a>
<div class="text"> 8月份的维多利亚</div>
</div>
<div class="image">
<a href="#" target="_self">
<img src="timg.jpg" alt="风景" width="300px" height="300px">
</a>
<div class="text"> 8月份的维多利亚</div>
</div>
</div>
</body>
</html>
3.6.1 选择器——选择器1
第一个文件style.css
h1,h2{
font-size: 45px;
}
*{
color:green;
margin: 0px;
padding: 0px;
}
a.div{
color: purple;
}
.p1{
color:blue;
}
.p2{
font-size:30px;
}
.p3{
font-style:italic;
}
第二个文件 67. html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>选择器</title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<p>Hello world!</p>
<h1>标题1</h1>
<h2>标题2</h2>
Hello~~
<div class="div">
Hello Jikexueyuan
</div>
<a class="div">jikexueyuan</a>
<p class="p1">This is my web page</p>
<p class="p2">THis is my web page</p>
<p class="p1 p2">THIs is my web page</p> <!--多类选择器-->
</body>
</html>