transformプロパティのtranslate ()、translateX()、translateY()、translateZ()、translate3d()は、要素の表示位置を移動させる際に使用します。
p.sample1, p.sample2, p.sample3, p.sample4, p.sample5 {background-color:limegreen;}
p.sample1 img {transform: translate(50px,20px);}
p.sample2 img {transform: translateX(50px);}
p.sample3 img {transform: translateY(20px);}
p.sample4 img {transform: translateZ(10px);}
p.sample5 img {transform: translate3d(50px,20px,10px);}
<html>
<head>
<link rel=”stylesheet” href=”sample.css”
type=”text/css”>
</head>
<body>
<p class=”sample1″>
translate(50px,20px)<br>
<img src=”https://www.htmq.com/wp-content/uploads/2024/07/kaeru.gif”>
</p>
<p class=”sample2″>
translateX(50px)<br>
<img src=”https://www.htmq.com/wp-content/uploads/2024/07/kaeru.gif”>
</p>
<p class=”sample3″>
translateY(20px)<br>
<img src=”https://www.htmq.com/wp-content/uploads/2024/07/kaeru.gif”>
</p>
<p class=”sample4″>
translateZ(10px)<br>
<img src=”https://www.htmq.com/wp-content/uploads/2024/07/kaeru.gif”>
</p>
<p class=”sample5″>
translate3d(50px,20px,10px)<br>
<img src=”https://www.htmq.com/wp-content/uploads/2024/07/kaeru.gif”>
</p>
</body>
</html>
translate(50px,20px)
translateX(50px)
translateY(20px)
translateZ(10px)
translate3d(50px,20px,10px)
p.prefix_sample1, p.prefix_sample2, p.prefix_sample3, p.prefix_sample4, p.prefix_sample5 {background-color:limegreen;}
p.prefix_sample1 img {
-moz-transform: translate(50px,20px);
-webkit-transform: translate(50px,20px);
-o-transform: translate(50px,20px);
-ms-transform: translate(50px,20px);
}
p.prefix_sample2 img {
-moz-transform: translateX(50px);
-webkit-transform: translateX(50px);
-o-transform: translateX(50px);
-ms-transform: translateX(50px);
}
p.prefix_sample3 img {
-moz-transform: translateY(20px);
-webkit-transform: translateY(20px);
-o-transform: translateY(20px);
-ms-transform: translateY(20px);
}
p.prefix_sample4 img {
-moz-transform: translateZ(10px);
-webkit-transform: translateZ(10px);
-o-transform: translateZ(10px);
-ms-transform: translateZ(10px);
}
p.prefix_sample5 img {
-moz-transform: translate3d(50px,20px,10px);
-webkit-transform: translate3d(50px,20px,10px);
-o-transform: translate3d(50px,20px,10px);
-ms-transform: translate3d(50px,20px,10px);
}
<html>
<head>
<link rel=”stylesheet” href=”sample.css” type=”text/css”>
</head>
<body>
<p class=”prefix_sample1″>
translate(50px,20px)<br>
<img src=”https://www.htmq.com/wp-content/uploads/2024/07/kaeru.gif”>
</p>
<p class=”prefix_sample2″>
translateX(50px)<br>
<img src=”https://www.htmq.com/wp-content/uploads/2024/07/kaeru.gif”>
</p>
<p class=”prefix_sample3″>
translateY(20px)<br>
<img src=”https://www.htmq.com/wp-content/uploads/2024/07/kaeru.gif”>
</p>
<p class=”prefix_sample4″>
translateZ(10px)<br>
<img src=”https://www.htmq.com/wp-content/uploads/2024/07/kaeru.gif”>
</p>
<p class=”prefix_sample5″>
translate3d(50px,20px,10px)<br>
<img src=”https://www.htmq.com/wp-content/uploads/2024/07/kaeru.gif”>
</p>
</body>
</html>
translate(50px,20px)
translateX(50px)
translateY(20px)
translateZ(10px)
translate3d(50px,20px,10px)