css3過(guò)度動(dòng)畫
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>CSS3過(guò)渡動(dòng)畫</title>
<style type="text/css">
.box{
width: 100px;
height: 100px;
background-color: gold;
/*在哪產(chǎn)生動(dòng)畫、動(dòng)畫的時(shí)間、運(yùn)動(dòng)曲線、延遲*/
/*transition: border-radius 500ms ease,width 500ms ease 500ms,height 500ms ease 1s,background-color 500ms ease 1.5s;*/
transition: all 500ms ease;
}
.box:hover{
width: 500px;
height: 300px;
background-color: red;
border-radius: 50px;
}
</style>
</head>
<body>
<div class="box"></div>
</body>
</html>
css3圓角、陰影、透明度
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>css3圓角 陰影 透明度</title>
<style type="text/css">
.box{
width: 200px;
height: 200px;
border: 2px solid #000;
background-color: gold;
margin: 50px auto 0;
/*border-top-left-radius: 100px 50px;左上角為橢圓圓角*/
/*border-top-left-radius: 100px;
border-top-right-radius: 100px;左、右上角為正圓圓角*/
/*border-radius: 40px;曲率半徑為40的圓角矩形*/
/*border-radius: 20%;最大200px,20%即40px*/
border-radius: 50%;/*正圓*/
}
.box1{
width: 200px;
height: 40px;
background-color: gold;
margin: 100px auto 0;
/*水平偏移 垂直偏移 羽化大小 擴(kuò)展大小 顏色*/
box-shadow: 10px 10px 10px 0px #bfa;
}
.box2{
width: 200px;
height: 40px;
background-color: gold;
margin: 100px auto 0;
/*水平偏移 垂直偏移 羽化大小 擴(kuò)展大小 顏色 是否內(nèi)陰影*/
box-shadow: 0px 0px 20px 2px red inset;
}
body{
background-color: cyan;
}
.box3{
width: 200px;
height: 200px;
/*background: url(images/location_bg.jpg);*/
background-color: gold;
margin: 50px auto 0;
border: 2px solid #000;
border-radius: 50%;
/*透明度30%,文字也透明了*/
opacity: 0.3;
filter: alpha(opacity=30);/*兼容IE*/
text-align: center;
line-height: 200px;
}
.box4{
width: 200px;
height: 200px;
/*背景色變透明,但文字不會(huì)透明*/
background-color: rgba(255,215,0,0.3);
margin: 50px auto 0;
/*邊框透明*/
border: 2px solid rgba(0,0,0,0.3);
border-radius: 50%;
text-align: center;
line-height: 200px;
}
</style>
</head>
<body>
<div class="box"></div>
<div class="box1"></div>
<div class="box2"></div>
<div class="box3">床前明月光</div>
<div class="box4">床前明月光</div>
</body>
</html>
運(yùn)動(dòng)曲線
!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>運(yùn)動(dòng)曲線</title>
<style type="text/css">
div{
width: 50px;
height: 50px;
background-color: gold;
margin-bottom: 20px;
}
div:nth-child(1){
/*勻速*/
transition: all 1s linear;
}
div:nth-child(2){
/*開始和結(jié)束慢速,中間加速*/
transition: all 1s ease;
}
div:nth-child(3){
/*開始慢速,結(jié)尾突然停止*/
transition: all 1s ease-in;
}
div:nth-child(4){
/*突然開始,結(jié)束時(shí)慢速*/
transition: all 1s ease-out;
}
div:nth-child(5){
/*開始和結(jié)束時(shí)慢速*/
transition: all 1s ease-in-out;
}
div:nth-child(6){
/*貝塞爾(貝茲)曲線*/
/*transition: all 1s cubic-bezier(0.250,0.250,0.750,0.750);勻速*/
/*超出再縮回的彈性效果*/
transition: all 1s cubic-bezier(0.470, -0.485, 0.460, 1.435);
}
div:hover{
width: 1000px;
}
</style>
</head>
圖片文字遮罩
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>圖片文字遮罩</title>
<style type="text/css">
.box{
width: 200px;
height: 300px;
margin: 50px auto 0;
border: 1px solid #000;
position: relative;
/*默認(rèn)文字不可見*/
overflow: hidden;
}
.box img{
width: 200px;
height: 300px;
}
.box .pic_info{
width: 200px;
height: 200px;
background-color: rgba(0,0,0,0.5);
color: #fff;
/*定位使色塊在圖片正下方*/
position: absolute;
left: 0;
top: 300px;
transition: all 500ms cubic-bezier(0.470, -0.485, 0.460, 1.435);
}
.box:hover .pic_info{
/*色塊上移*/
top:150px;
}
/*間距用p標(biāo)簽的margin,而不直接給.pic_info用padding,因?yàn)閜adding會(huì)改變盒子大小*/
.box .pic_info p{
margin: 20px;
line-height: 30px;
}
</style>
</head>
變形
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>變形</title>
<style type="text/css">
.box,.box2,.box3,.box4{
width: 200px;
height: 200px;
background-color: gold;
margin: 50px auto 0;
transition: all 1s ease;
}
.box:hover{
/*box的動(dòng)畫不會(huì)影響到box2*/
/*位移*/
transform: translate(50px,50px);
}
.box2:hover{
/*沿Z軸旋轉(zhuǎn)360度*/
transform: rotate(360deg);
}
.box3:hover{
/*縮放*/
transform: scale(0.5,0.2);
}
.box4:hover{
/*斜切*/
/*transform: skew(45deg,0);*/
transform: skew(0,45deg);
}
</style>
</head>
<body>
<div class="box"></div>
<div class="box2"></div>
<div class="box3"></div>
<div class="box4"></div>
</body>
</html>
元素旋轉(zhuǎn)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>元素旋轉(zhuǎn)</title>
<style type="text/css">
/*旋轉(zhuǎn)方向判斷
1、X軸向右、Y軸向下、Z軸向屏幕外
2、讓軸向?qū)χ约?,順時(shí)針方向就是該軸向的旋轉(zhuǎn)方向*/
.box{
width: 300px;
height: 300px;
background-color: gold;
margin: 50px auto 0;
transition: all 500ms ease;
/*設(shè)置盒子按3D空間顯示*/
transform-style: preserve-3d;
transform: perspective(800px) rotateY(0deg);
}
.box:hover{
/*默認(rèn)沿Z軸旋轉(zhuǎn)*/
/*transform: rotate(45deg);*/
/*perspective設(shè)置透視距離,經(jīng)驗(yàn)數(shù)值800比較符合人眼的透視效果*/
/*transform: perspective(800px) rotateX(45deg);*/
transform: perspective(800px) rotateY(-45deg);
}
</style>
</head>
<body>
<div class="box"></div>
</body>
</html>