/    Sign up×
Community /Pin to ProfileBookmark

CSS3 amination-rotating

Hello,

Could someone please explain why we can always see the images of the dogs, when the pictures are rotating?

In reality when a picture is rotating to 180degree, we just can see the back of the image.

I’ve loaded the relevant codes and image to Onedrive.
https://1drv.ms/u/s!AiDyXpbc9x3ZgTmQ3PZ3_9w_X3yV?e=Og94hS

[code]
<!DOCTYPE html>
<html lang=”en”>

<head>
<meta charset=”UTF-8″>
<meta name=”viewport” content=”width=device-width, initial-scale=1.0″>
<title>Document</title>
<style>
body {
perspective: 1000px;
}

section {
position: relative;
width: 300px;
height: 200px;
margin: 150px auto;
transform-style: preserve-3d;
animation: rotate 10s linear infinite;
}

section:hover {
animation-play-state: paused;
}

@keyframes rotate {
0% {
transform: rotateY(0);
}
100% {
transform: rotateY(360deg);
}
}

section div {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
/* background: url(media/dog.jpg); */
}

section div:nth-child(1) {
transform: rotateY(0) translateZ(300px);
}

section div:nth-child(2) {
transform: rotateY(60deg) translateZ(300px);
}

section div:nth-child(3) {
transform: rotateY(120deg) translateZ(300px);
}

section div:nth-child(4) {
transform: rotateY(180deg) translateZ(300px);
}

section div:nth-child(5) {
transform: rotateY(240deg) translateZ(300px);
}

section div:nth-child(6) {
transform: rotateY(300deg) translateZ(300px);
}
</style>
</head>

<body>
<section>
<div>
<img src=”media/dog.jpg” alt=””>
</div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
</section>

</body>

</html>[/code]

to post a comment

3 Comments(s)

Copy linkTweet thisAlerts:
@SempervivumJan 26.2020 — Check if this helps you:

https://css-tricks.com/almanac/properties/b/backface-visibility/

BTW: You better use code tags instead of backtics: `your code here`

I edited your post accordingly.
Copy linkTweet thisAlerts:
@tree123authorJan 26.2020 — @Sempervivum#1613686

Thank you very much for helping me out and editing the post for me. I have been puzzled at this question for quite a few days, and also posted this question on another forum, yet no one answered it correctly.

I will use code tag next time.

Have a great one!
Copy linkTweet thisAlerts:
@tree123authorJan 29.2020 — Hello again,

Would someone please tell me why the .dog2 cannot rotate to 60degrees in the following code?

This is almost same to the code of the first post in this thread from which I transcribed in the tutorial I am learning. Today I go it over, and would like to do it myself completely, so the codes are slightly different from those of the first post, but generally it is same.

I've added "transform-style" to .box as well perspective.

<i>
</i>&lt;!DOCTYPE html&gt;
&lt;html lang="en"&gt;

&lt;head&gt;
&lt;meta charset="UTF-8"&gt;
&lt;meta name="viewport" content="width=device-width, initial-scale=1.0"&gt;
&lt;meta http-equiv="X-UA-Compatible" content="ie=edge"&gt;
&lt;title&gt;Document&lt;/title&gt;
&lt;style&gt;
body {
perspective: 400px;
}
<br/>
<i> </i> .box {
<i> </i> position: relative;
<i> </i> width: 300px;
<i> </i> height: 200px;
<i> </i> margin: 200px auto;
<i> </i> transform-style: preserve-3d;
<i> </i> }
<i> </i>
<i> </i> div[class^="dog"] {
<i> </i> position: absolute;
<i> </i> top: 0;
<i> </i> left: 0;
<i> </i> width: 100%;
<i> </i> height: 100%;
<i> </i> background-color: pink;
<i> </i> background: url(media/dog.jpg);
<i> </i> }
<i> </i>
<i> </i> dog1 {
<i> </i> transform: rotateY(0) translateZ(200px);
<i> </i> }
<i> </i>
<i> </i> dog2 {
<i> </i> transform: rotateY(60deg) translateZ(200px);
<i> </i> }
<i> </i>&lt;/style&gt;
&lt;/head&gt;

&lt;body&gt;
&lt;div class="box"&gt;
&lt;div class="dog1"&gt;&lt;/div&gt;
&lt;div class="dog2"&gt;&lt;/div&gt;
&lt;div class="dog3"&gt;&lt;/div&gt;
&lt;div class="dog4"&gt;&lt;/div&gt;
&lt;div class="dog5"&gt;&lt;/div&gt;
&lt;div class="dog6"&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;/body&gt;

&lt;/html&gt;
×

Success!

Help @tree123 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 4.26,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...