CSS3 transform: translate3d ne modifie pas l'axe z?
-
27-10-2019 - |
Question
Je cet extrait mis en œuvre:
CSS
div
{
position:absolute;
-webkit-transition: all 0.3s ease-out;
}
.block
{
background:#fc0; /* YELLOW */
top:50px;
left:50px;
width:80px;
height:40px;
-webkit-transform: rotate3d(1,0,0,-55deg) rotate3d(0,0,1,30deg);
}
.block .part
{
background:#444; /* GREY */
width:inherit;
height:inherit;
-webkit-transform: translate3d(0,0,50px);
}
.block:hover .part
{
-webkit-transform: translate3d(10px,10px,20px); /* ONLY TRANSFORMS X & Y */
}
HTML
<div class="block">
<div class="part"></div>
</div>
Consultez ce Fiddle pour l'exemple vivant.
Comme vous pouvez le voir, la traduction sur :hover
affecte uniquement la .part
sur la x - et axe y .
Il ne se traduira pas dans la direction z.
Toute personne qui sait ce que je fais mal?
La solution
Got it. Vous avez oublié d'ajouter -webkit-transform-style: preserve-3d;
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow