一、2D形變
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>2d形變</title>
<style type="text/css">
body{
}
div{
width: 200px;
height: 200px;
background-color: gray;
text-align: center;
line-height: 200px;
font-size: 30px;
margin-left: 100px;
float: left;
color: black;
transition: 2s linear;
}
.rotate{
transform: rotate(0deg);
}
.rotate:hover{
transform: rotate(360deg);
}
.translate{
transform: translate(0px,0px);
}
.translate:hover{
transform: translate(10px,10px);
}
.scale{
transform: scale(0.5,2);
}
.skew{
transform: skewX(10deg);
}
</style>
</head>
<body>
<div class="rotate">旋轉</div>
<div class="translate">平移</div>
<div class="scale">縮放</div>
<div class="skew">傾斜
</div>
</body>
</html>
二、定位
body{
height: 1200px;
}
1.relative相對定位
2.absolute絕對定位
3.fixed固定定位
4.abstract默認定位*/
.redDiv,.blueDiv{
width: 200px;
height: 200px;
}
.redDiv{
position: relative;
left: 10px;
bottom: 20px;
background-color: red;
}
.blueDiv{
background-color: blue;
}
.greenDiv{
position: absolute;
right: 0px;
bottom: 0px;
width: 50px;
height: 50px;
background-color: green;
z-index:2;
}
.ad{
width: 100px;
height: 380px;
background-color: gray;
color: white;
font-size: 20px;
position: fixed;
right: 20px;
top: 50%;
margin-top: -190px;
}