ä¸ãtransform
Transformæ¯å½¢åçææ(é常ä¹å«åæ¢),transformerå°±æ¯åå½¢éå
常è§çå½æ°transform functionæ:
平移:translate(x, y)
缩æ¾:scale(x, y)
æ转:rotate(deg)
å¾æ:skew(deg, deg
äºãrotate(æ转)
该CSSå½æ°å®ä¹ä¸ä¸ªåæ¢,å®å°å ç´ å´ç»åºå®è½´æ转ãæ转éç±æå®çè§åº¦ç¡®å®; 为æ£,æ转å°ä¸ºé¡ºæ¶é,为è´,å为éæ¶éã
åªæä¸ä¸ªå¼,表示æ转çè§åº¦(åä½deg)
ä¸ãtranslate(平移)
translateX(x)ãtranslateY(y)ãtranslateZ(z)
该å½æ°è¡¨ç¤ºå¨äºãä¸ç»´å¹³é¢ä¸ç§»å¨å ç´
åãscale(缩æ¾)
scaleXãscaleYãscaleZ
å½æ°æå®äºä¸ä¸ªæ²¿ xãy ãzè½´è°æ´å ç´ ç¼©æ¾æ¯ä¾å å 1:ä¿æä¸å
 2:æ¾å¤§ä¸å
0.5:缩å°ä¸å
äºãtransform-style(éæ©3D)Â
transform-style
该CSSå±æ§ç¨äºè®¾ç½®å ç´ çåå ç´ æ¯å®ä½å¨ 3D 空é´ä¸è¿æ¯å¹³å±å¨å ç´ ç2Då¹³é¢ä¸
flat:æ示å ç´ çåå ç´ ä½äºå ç´ æ¬èº«çå¹³é¢å ã
preserve-3d:æ示å ç´ çåå ç´ åºä½äº 3D 空é´ä¸
 å ãå¶ä½ä¸ä¸ªæ£æ¹ä½
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
</head>
<style>
body {
margin: 0;
padding: 100px;
background-color: aqua;
}
.box {
position: relative;
width: 100px;
height: 100px;
background-color: red;
/* å¨ç¶å
ç´ ä¸æ·»å transform-styleæ¥å¯ç¨3Dç©ºé´ */
transform-style: preserve-3d;
transform: rotateX(-33.5deg) rotateY(45deg);
}
.item {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
.top {
/* translateZ(50px)åä¸å¹³ç§» */
transform: rotateX(90deg) translateZ(50px);
background-color: antiquewhite;
}
.bottom {
background-color: rgba(190, 216, 76, 0.712);
transform: rotateX(-90deg) translateZ(50px);
}
.front {
background-color: rgba(100, 100, 100, 0.4);
transform: rotateY(0deg) translateZ(50px);
}
.back {
background-color: rgba(0, 255, 255, 0.4);
transform: rotateY(-180deg) translateZ(50px);
}
.left {
background-color: rgba(221, 103, 182, 0.4);
transform: rotateY(-90deg) translateZ(50px);
}
.right {
background-color: rgba(0, 0, 255, 0.4);
transform: rotateY(90deg) translateZ(50px);
}
</style>
<body>
<div class="box">
div
<!-- åå
ç´ -->
<div class="item top">1</div>
<div class="item bottom">2</div>
<div class="item front">3</div>
<div class="item back">4</div>
<div class="item left">5</div>
<div class="item right">6</div>
</div>
</body>
</html>
Â