Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Backface Visibility not working on children

This solutions (Webkit backface visibility not working) didn't work, as I'd like to have other transformed objects inside container that should show the backface.

.container {
  position: relative;
  transform-origin: 50% 50% 0;
  transition: transform 1s ease 0s;
  width: -moz-min-content;
  width: -webkit-min-content;
}
.container img {
  backface-visibility: hidden;
}
input:checked + .container {
  transform: rotateY(180deg);
}
<input type="checkbox" name="" id="" />
<div class="container">
  <img src="http://jsequeiros.com/sites/default/files/imagen-cachorro-comprimir.jpg" alt="" />
</div>

The backface of that cat shouldn't be visible. Any solution for this problem?

like image 801
Vandervals Avatar asked Jun 17 '15 12:06

Vandervals


People also ask

How does Backface-visibility work?

The backface-visibility property defines whether or not the back face of an element should be visible when facing the user. The back face of an element is a mirror image of the front face being displayed. This property is useful when an element is rotated. It lets you choose if the user should see the back face or not.

Can I use Backface-visibility hidden?

That's because the default for backface-visibility is visible . Instead of it being visible, you could hide it.

What happens when an element is styled as follows Backface-visibility hidden?

The back face is visible when turned towards the user. The back face is hidden, effectively making the element invisible when turned away from the user.


2 Answers

I finally discovered how to solve this! The problem was the the 3d was not affecting the image. Just by adding the property: transform-style: preserve-3d; includes the image as part of the "3d world". Before, the backface property wasn't working, because it really wasn't 3d! It was like a texture painted on the parent's surface. Now it is a 3d entity with all its components and it can be transformed in 3d without collapsing to the surface of the parent.

.container {
  position: relative;
  transform-origin: 50% 50% 0;
  transition: transform 1s ease 0s;
  width: -moz-min-content;
  width: -webkit-min-content;
  transform-style: preserve-3d;
}
.container img {
  backface-visibility: hidden;
}
input:checked + .container {
  transform: rotateY(180deg);
}
<input type="checkbox" name="" id="" />
<div class="container">
  <img src="http://jsequeiros.com/sites/default/files/imagen-cachorro-comprimir.jpg" alt="" />
</div>
like image 132
Vandervals Avatar answered Oct 09 '22 14:10

Vandervals


EDIT setting backface-visibility: hidden; on the elem you're transforming solve the issue

.container {
  position: relative;
  transform-origin: 50% 50% 0;
  transition: transform 1s ease 0s;
  width: -moz-min-content;
  width: -webkit-min-content;
}
.container{
  backface-visibility: hidden;
  
}
input:checked + .container {
  transform: rotateY(180deg);
}
<input type="checkbox" name="" id="" />
<div class="container">
  <img src="http://todofondosdeamor.com/wp-content/uploads/images/48/gatitos-1__400x300.jpg" alt="" />
</div>
like image 33
maioman Avatar answered Oct 09 '22 14:10

maioman