- 边框(border)
边框的圆角(border-radius)
边框阴影(box-shadow)
边框的图片(border-image/border-image-source)
Border-image-repeat:边框图片平铺方式
Border-image-slice: 图片裁剪区域
Border-image-width: 边框图片的厚度
Border-image-ouset:设置边框背景图向外拓展的距离
案例::
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title></title>
<style type="text/css">
div{
/*border: 1px solid red;*/
background: #666;
}
p{
color:#666;
font-family: "微软雅黑";
font-size: 50px;
font-weight: 900;
margin: auto;
text-shadow: -1px -1px 1px #fff,1px 1px 1px #000;
}
span{
color:#666;
font-family: "微软雅黑";
font-size: 50px;
font-weight: 900;
margin: auto;
text-shadow: -1px -1px 1px #000,1px 1px 1px #fff;
}
</style>
</head>
<body>
<div>
<p>心之所向,梦之所往</p>
<span>心之所向,梦之所往</span>
</div>
</body>
</html>
2.浏览器的私有化前缀
-moz: 设置火狐的私有化前缀
-webkit: 设置苹果和谷歌
-o : 设置欧朋浏览器的前缀
-ms: 设置IE的前缀
3.文本的阴影的属性
Text-shadow:10px(水平偏移量) 20px(垂直的偏移量) 10px(模糊程度) 2px(阴影的大小)
多个阴影显示
Text-shadow:10px(水平偏移量) 20px(垂直的偏移量) 10px(模糊程度) 2px(阴影的大小) #fff(阴影的颜色),10px(水平偏移量) 20px(垂直的偏移量) 10px(模糊程度) 2px(阴影的大小) #fff(阴影的颜色)
内阴影:Text-shadow:inset 10px(水平偏移量) 20px(垂直的偏移量) 10px(模糊程度) 2px(阴影的大小) #fff(阴影的颜色)
注:模糊度不能为负值
4.盒子模型
盒子模型具备的条件:
- Content(内容)
- Padding(内边距)
- Border(边框)
- Margin(外边距)
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<style type="text/css">
div{
width: 300px;
height: 150px;
/*border: 1px solid red;*/
float: left;
margin-top: 50px;
margin-right: 20px;
}
img{
/*width: 300px;
height: 150px;*/
width: 100%;
height: 100%;
}
div:hover{
border: 5px solid gray;
}
</style>
</head>
<body>
<div>
<img src="img/1.jpg" />
</div>
<div>
<img src="img/2.jpg" />
</div>
<div>
<img src="img/3.jpg" />
</div>
</body>
</html>
5.背景
(1) 背景尺寸:backgroun-size
(2)背景原点/起始点:background-origin
属性:border-box(以边框为起始点)
content-box(以内容为起始点,是默认值)
padding-box(以内边距为起始点)
(3)背景裁剪:background-clip (属性同background-0rigin)
(4)多背景:background: url(img/bg1.png) left top no-repeat,
url(img/bg2.png)right top no-repeat,
url(img/bg3.png) right bottom no-repeat,
url(img/bg4.png) left bottom no-repeat,
url(img/bg5.png) no-repeat center center;
案例
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title></title>
<style type="text/css">
.wrap{
width: 300px;
height: 250px;
border: 10px solid rgba(0,255,0,0.2);
padding: 30px;
background: url(img/baby0.jpg) no-repeat;
background-size: 200px 200px;
background-origin:border-box ;
/*background-origin: padding-box;*/
/*background-clip: padding-box;*/
background-clip: content-box;
}
.div{
width: 620px;
height: 417;
border: 1px solid red;
margin:300px auto;
background: url(img/bg1.png) left top no-repeat,
url(img/bg2.png)right top no-repeat,
url(img/bg3.png) right bottom no-repeat,
url(img/bg4.png) left bottom no-repeat,
url(img/bg5.png) no-repeat center center;
line-height: 417px;
text-align:center;
font-size:50px;
color:red;
font-family: "楷体";
}
</style>
</head>
<body>
<div class="wrap"></div>
<div class="div">流传千古</div>
</body>
</html>
7.渐变
(1)线性渐变:linear-gradient();
(2)径向渐变:radial-gradient();
案例1:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<style type="text/css">
div{
width: 500px;
height: 50px;
border: 1px solid black;
margin: 50px auto;
}
.div01{
background:linear-gradient(to left,red,yellow)
}
.div02{
background:linear-gradient(120deg,green,yellow)
}
.div03{
background:linear-gradient(90deg,
yellow 0%,
pink 25%,
blue 75%,
red 100%
)
}
.div04{
background: linear-gradient(120deg,
black 0%,black 25%,
yellow 25%,yellow 50%,
green 50%,green 75% ,
red 75%,red 100%
)
}
</style>
</head>
<body>
<div class="div01"></div>
<div class="div02"></div>
<div class="div03"></div>
<div class="div04"></div>
</body>
</html>
案例2:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<style type="text/css">
div{
width: 200px;
height: 200px;
border: 1px solid black;
margin: 50px auto;
}
.div01{
background: radial-gradient(at center,yellow,green);
}
.div02{
background: radial-gradient(at left top,yellow,green);
}
.div03{
background: radial-gradient( at 50px 50px,yellow,pink,green,red);
}
.div04{
background: radial-gradient(100px at 50px 50px,yellow,pink,green,red);
}
.div05{
background: radial-gradient(100px 50px at center,yellow,green);
}
</style>
</head>
<body>
<div class="div01"></div>
<div class="div02"></div>
<div class="div03"></div>
<div class="div04"></div>
<div class="div05"></div>
</body>
</html>
8.过渡:transition
transition:param1 param2
param1表示要过渡的属性,param2表示要过渡的时间
属性:(1)设置过渡的属性:transition-property:left;
(2)设置过渡时间:transition-duration:2s;
(3)设置过渡的延迟加载:transition-timing-function:linear;
linear:线性过渡。
ease:平滑过渡。
ease-in:由慢到快。
ease-out:由快到慢。
ease-in-out:由慢到快再到慢。
step-start:等同于 steps(1, start)
step-end:等同于 steps(1, end)
steps(<integer>[, [ start | end ] ]?):接受两个参数的步进函数。第一个参数必须为正整数,指定函数的步数。第二个参数取值可以是start或end,指定每一步的值发生变化的时间点。第二个参数是可选的,默认值为end。
cubic-bezier(<number>, <number>, <number>, <number>):特定的贝塞尔曲线类型,4个数值需在[0, 1]区间内
案例:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<style type="text/css">
.wrap{
width: 200px;height: 200px;
border: 1px solid black;
margin: 50px;
background: pink;
transition: all 2s;
}
.wrap:hover{
background: red;
width: 500px;
}
.boss{
width: 200px;height: 200px;
border: 1px solid black;
margin: 120px;
background: pink;
transition:all 2s;
transition-timing-function: ease;
/*transition-property: left;*/
}
.boss:hover{
width: 500px;height:500px;
/*background: blueviolet;*/
border-radius: 50px;
background: url(img/baby0.jpg) no-repeat;
background-size: 100% 100%;
}
</style>
</head>
<body>
<div class="wrap"></div>
<div class="boss"></div>
</body>
</html>
延伸JS小知识(动画效果)
案例:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<style type="text/css">
div{
border: 1px solid black;
width: 1000px;
height: 100px;
margin: 100px auto;
}
.wrap{
background: linear-gradient(135deg,
#000 0%,
#000 25%,
red 25%,
red 50%,
#000 50%,
#000 75%,
red 75%,
red 100%
);
background-size:100px 100px ;
animation:move 1s linear infinite;
}
@keyframes move{
from{
background-position: 0px 0px;
}
to{
background-position: -100px 0px;
}
}
</style>
</head>
<body>
<div class="wrap"></div>
</body>
</html>