01选择器续
DOCTYPE html >
< html lang = " en" >
< head>
< meta charset = " UTF-8" >
< title> Title title>
< style>
body>div>p {
color : red;
}
a:link { color : red}
a:visited { color : green}
a:hover { color : yellow}
a:active { color : blue}
style>
head>
< body>
< a href = " http://www.tedu.cn" > 超链接1 a>
< a href = " http://www.baidu.com" > 超链接2 a>
< a href = " http://www.youku.com" > 超链接3 a>
< p> p1 p>
< div>
< p> p2 p>
< div> < p> p3 p> div>
< div>
< p> p4 p>
< div> < p> p5 p> div>
div>
div>
body>
html>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
2.选择器练习
DOCTYPE html >
< html lang = " en" >
< head>
< meta charset = " UTF-8" >
< title> Title title>
< style>
#gy { color : green}
.c1 { color : yellow}
input[type='text'],body>p { background-color : red}
body>div>div>p { color : pink}
a:link { color : green}
a:visited { color : red}
a:hover { color : yellow}
a:active { color : pink}
style>
head>
< body>
< ul>
< li> 刘备 li> < li id = " gy" > 关羽 li> < li class = " c1" > 张飞 li>
ul>
< p> 香蕉 p> < p class = " c1" > 苹果 p>
< input type = " text" >
< input type = " password" >
< div>
< p> p1 p>
< div> < p> p2 p> div>
< div> < div> < p> p3 p> div> div>
div>
< a href = " http://www.qq.com" > 腾讯官网 a>
body>
html>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
3.颜色赋值
三原色RGB RedGreenBlue , 每种颜色的取值范围0-255 五种赋值方式:
颜色单词赋值: red/green/blue/yellow/pink… 6位16进制: #ff 00 00 3位16进制: #f00 3位10进制: rgb(255,0,0) 4位10进制: rgba(255,0,0,0-1) a=alpha 透明度 值越小越透明
DOCTYPE html >
< html lang = " en" >
< head>
< meta charset = " UTF-8" >
< title> Title title>
< style>
h1 {
color : red;
color : #00ff00;
color : #00f;
color : rgb ( 255, 255, 0) ;
color : rgba ( 255, 0, 0, 0.2) ;
}
#d1 {
width : 200px;
height : 200px;
background-color : purple;
background-image : url ( "../imgs/a.jpg" ) ;
background-size : 100px 100px;
background-repeat : no-repeat;
background-position : 20px 50px;
background-position : 80% 80%;
}
#d2 {
width : 611px;
height : 376px;
background-color : #e8e8e8;
background-image : url ( "http://doc.canglaoshi.org/tstore_v1/images/itemCat/study_computer_img1.png" ) ;
background-repeat : no-repeat;
background-size : 318px 319px;
background-position : 90% 80%;
}
style>
head>
< body>
< div id = " d2" > div>
< div id = " d1" > 背景测试 div>
< h1> 颜色测试 h1>
body>
html>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
4.文本和字体
DOCTYPE html >
< html lang = " en" >
< head>
< meta charset = " UTF-8" >
< title> Title title>
< style>
div {
width : 200px;
height : 40px;
text-align : center;
text-decoration : line-through;
line-height : 40px;
text-shadow : green 5px 5px 5px;
font-size : 20px;
font-weight : bold;
font : 30px cursive;
}
a { text-decoration : none}
h1 {
font-weight : normal;
font-style : italic;
font-family : cursive;
}
style>
head>
< body>
< h1> 这是h1 h1>
< a href = " " > 超链接 a>
< div> 文本和字体 div>
body>
html>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
5.文本和字体练习
DOCTYPE html >
< html lang = " en" >
< head>
< meta charset = " UTF-8" >
< title> Title title>
< style>
#d1 {
width : 100px;
height : 30px;
background-color : green;
color : red;
text-align : center;
line-height : 30px;
}
span {
font-size : 25px;
font-style : italic;
}
#bx {
font-weight : normal;
text-shadow : blue -5px 5px 3px;
}
#xyj {
text-decoration : underline;
}
a {
text-decoration : none;
font-weight : bold;
font-size : 20px;
}
style>
head>
< body>
< div id = " d1" > 刘德华 div> < div> 张学友 div>
< span> 香蕉 span>
< span> 苹果 span>
< h1 id = " bx" > 冰箱 h1>
< h1 id = " xyj" > 洗衣机 h1>
< a href = " http://www.baidu.com" > 百度 a>
body>
html>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
6.显示方式
DOCTYPE html >
< html lang = " en" >
< head>
< meta charset = " UTF-8" >
< title> Title title>
< style>
div {
border : 1px solid red;
width : 100px;
height : 100px;
}
span {
border : 1px solid blue;
width : 100px;
height : 100px;
}
img {
width : 100px;
height : 100px;
}
a {
background-color : #0aa1ed;
width : 132px;
height : 40px;
display : block;
text-align : center;
line-height : 40px;
color : white;
text-decoration : none;
font-size : 20px;
border-radius : 3px;
}
style>
head>
< body>
< a href = " " > 查看详情 a>
< img src = " ../imgs/a.jpg" alt = " " >
< img src = " ../imgs/a.jpg" alt = " " >
< img src = " ../imgs/a.jpg" alt = " " >
< div> div1 div>
< div> div2 div>
< div> div3 div>
< span> span1 span>
< span> span2 span>
< span> span3 span>
body>
html>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
DOCTYPE html >
< html lang = " en" >
< head>
< meta charset = " UTF-8" >
< title> Title title>
< style>
#d1 {
width : 100px;
height : 100px;
border : 1px solid red;
margin : 50px;
margin : 100px 50px;
margin : 10px 20px 30px 40px;
}
#d2 {
width : 100px;
height : 100px;
border : 1px solid red;
margin-top : 50px;
}
#s1 {
margin-right : 50px;
}
#s2 {
margin-left : 30px;
}
#big {
width : 200px;
height : 200px;
background-color : green;
overflow : hidden;
}
#big>div {
width : 50px;
height : 50px;
background-color : blue;
margin-left : 50px;
margin-top : 50px;
}
body {
margin : 0;
}
style>
head>
< body>
< h1> 这是h1 h1>
< p> 这是p p>
< ul>
< li> aaa li>
< li> bbb li>
< li> ccc li>
ul>
< div id = " big" >
< div> div>
div>
< span id = " s1" > span1 span> < span id = " s2" > span2 span>
< div id = " d1" > div>
< div id = " d2" > div>
body>
html>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
DOCTYPE html >
< html lang = " en" >
< head>
< meta charset = " UTF-8" >
< title> Title title>
< style>
#d1 {
width : 400px;
height : 200px;
border : 20px solid red;
border-radius : 200px;
}
#d2 {
width : 50px;
height : 50px;
border : 1px solid red;
padding-left : 50px;
padding-top : 50px;
}
style>
head>
< body>
< ul>
< li> aaa li>
< li> bbb li>
< li> ccc li>
ul>
< div id = " d2" > 内边距 div>
< div id = " d1" > 边框测试 div>
body>
html>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
DOCTYPE html >
< html lang = " en" >
< head>
< meta charset = " UTF-8" >
< title> Title title>
< style>
#d1 {
width : 100px;
height : 100px;
background-color : red;
overflow : hidden;
}
#d1>div {
width : 50px;
height : 50px;
background-color : blue;
margin : 25px 0 0 25px;
}
#d2 {
width : 50px;
height : 50px;
border : 5px solid green;
border-radius : 5px;
margin-left : 100px;
padding-left : 125px;
padding : 50px 0 0 50px;
box-sizing : border-box;
}
style>
head>
< body>
< div id = " d1" >
< div> div>
div>
< div id = " d2" > 哈喽 div>
body>
html>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
10.CSS三大特性
DOCTYPE html >
< html lang = " en" >
< head>
< meta charset = " UTF-8" >
< title> Title title>
< style>
body {
font-family : cursive;
}
#d1 {
color : red;
}
div {
color : green !important ;
}
p { color : blue; }
style>
head>
< body>
< div id = " d1" >
< p> 这是p标签 p>
< span> 这是span span>
< a href = " " > 超链接 a>
div>
body>
html>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27