Why is backface-visibility hidden not working in IE10 when perspective is applied to parent elements?
I came up against this glitch too and it is definitely a glitch.
The workaround is to apply the perspective transform on the child element. I updated your fiddle here: http://jsfiddle.net/jMe2c/
.item {
backface-visibility: hidden;
transform: perspective(200px) rotateX(0deg);
}
.container:hover .item {
transform: perspective(200px) rotateX(180deg);
}
(See also answer at https://stackoverflow.com/a/14507332/2105930)
I think it is because in IE 10, parent element 3d-properties do not propagate to the child element. This is a known unsupported feature. Check out http://msdn.microsoft.com/en-us/library/ie/hh673529%28v=vs.85%29.aspx#the_ms_transform_style_property:
At this time, Internet Explorer 10 does not support the preserve-3d keyword. You can work around this by manually applying the parent element's transform to each of the child elements in addition to the child element's normal transform.
So the Microsoft-recommended solution is to propagate your 3d properties yourself, manually.
Backface-visibility not working in IE10?
This ended up working for my problem ->
Demo here - demo
Html
<div class="panel">
<div class="card front">
<img src="images/panel.svg" height="100%" width="100%" />
</div>
<div class="card back">
<h4>User Experience</h4>
<p >
"Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."
</p>
</div>
</div>
CSS
.panel
{
-webkit-perspective: 1000;
-ms-perspective: 1000;
-moz-perspective: 1000;
perspective: 1000;
}
.panel, .card {
width: 80%;
height: 80%;
position:absolute;
top:0;
left:0;
background-color: #fff;
}
.card {
-webkit-transition: all 0.5s linear;
-ms-transition: all 0.5s linear;
-moz-transition: all 0.5s linear;
transition: all 0.5s linear;
-webkit-backface-visibility: hidden;
-ms-backface-visibility: hidden;
-moz-backface-visibility: hidden;
backface-visibility: hidden;
}
.grid_4 .back {
position: relative;
text-align:center; min-height: 100%;height: auto !important; width: 100%;
-ms-transform: rotateY(180deg);
-webkit-transform: rotateY(180deg);
-moz-transform: rotateY(180deg);
transform: rotateY(180deg);
}
.panel:hover .card {
-webkit-transform: rotateY(360deg);
-ms-transform: rotateY(360deg);
-moz-transform: rotateY(360deg);
transform: rotateY(360deg);
}
Problem apparently is that Preserve-3D
doesn't work in IE. There are a few changes - Instead of making the 'card' turn, the actualy 'container = panel' is made to turn.
backface-visibility doesn't work and perspective() issue
Rotating the children elements instead of the container would help achieve the effect you want.
Here is what we do in the below snippet:
- A container element which is transparent and has a
perspective
property assigned to it. Setting this on the parent automatically applies it to both children elements. - Two absolutely positioned block children elements who have 100% width and height of the parent container element. Both these elements have
background
as red. Theirbackface-visibility
is hidden which means that when the elements are rotated by +/- 180deg the backside is not shown (and thus the mirror appearance of text does not show up). - Initially the front element is not rotated and the back element is rotated by 180deg. This keeps the front element on top and sends the back element behind. Because of
backface-visibility
, the content of the element behind is hidden. - On hovering the container, the front element is rotated by -180deg and so it goes behind whereas the back element is brought to the front.
Regarding the other issue, I am not able to simulate it but I am confident that using this method should solve that issue also.
body { font-family: Arial; font-size: 40px; font-weight: bold; color: black;}.card { position: relative; width: 200px; height: 200px; margin: 100px auto; perspective: 2000px; /* applies to both children */}.back { transform: rotateY(180deg); /* originally this is behind */}.card:hover .back { transform: rotateY(0deg); /* on hover it is brought to front */}.card:hover .front { transform: rotateY(-180deg); /* on hover front is sent back */}.front,.back { position: absolute; display: inline-block; height: 100%; width: 100%; background: red; text-align: center; line-height: 200px; transition: transform 2s ease; backface-visibility: hidden;}
<div class="card"> <span class='front'>Front</span> <span class='back'>End</span></div>
Having trouble with perspective and backface-visibility
First of all, you have a syntax error:
.layer-1, layer-2 {
should be
.layer-1, .layer-2 {
Also, for this setup to work, you need to set
.poster {
transform-style: preserve-3D;
}
because you have transforms both in the parent and the child, and you want get the backface style to the combination of both. You had already this on body, but this property doesn't inherit.
Your snippet corrected
body { transform-style:preserve-3d; transform:perspective(1500px);}@keyframes rotating { from{ transform: rotateY(0deg); } to{ transform: rotateY(360deg); }}
.poster { animation: rotating 10s linear infinite;}
.poster { width:510px; height:310px; position:absolute; top:50%; left:50%; margin: 0 0 0 -256px; border-radius:4px; box-shadow:0 45px 100px rgba(0,0,0,0.4); transform-style: preserve-3D; /* new */}
.poster .shine { position:absolute; top:0; left:0; background:-webkit-linear-gradient(0deg,rgba(0,0,0,0) 0%,rgba(0,0,0,0) 60%); background:linear-gradient(135deg,rgba(0,0,0,0) 0%,rgba(0,0,0,0) 60%); z-index:100;}
.layer-1, .layer-2 { position:absolute; top:0; left:0; transform: translateZ(10px); -moz-backface-visibility: hidden; -webkit-backface-visibility: hidden; backface-visibility: hidden; -webkit-transition: .1s; transition: .1s;}.layer-1 {background-color: blue; color:white;}.layer-2 { background-color: red; transform:rotateY(180deg);}
<div class="poster"> <div class="layer-1">FRONT<img src="images/VS.svg" alt="Front" id="FRONT"></div> <div class="layer-2">BACK<img src="images/RS.svg" alt="Back" id="BACK"></div></div>
Css3 perspective-property not working in IE10
I have no clue why you have xpersepective
in your CSS, IE10 is unprefixed in CSS, however the perspective property must have some kind of unit for the depth, perspective: 1000
won't be applied because the browser doesn't know what unit it is in, similarly like width and height, etc, you have to apply px, em, etc. The only browsers that assume units (and in pixels) on the perspective
property are Webkit browsers, and only when it is inside the transform
property.
If you do a little research you, Microsoft states:
The W3C specification defines a keyword value of preserve-3d for this property, which indicates that flattening is not performed. At this time, Internet Explorer 10 does not support the preserve-3d keyword. You can work around this by manually applying the parent element's transform to each of the child elements in addition to the child element's normal transform.
So for now, you'll just have to implement the advised fix, if you want to go down that road.
If not, you're lucky. I spent time trying to make it transition smoothly over. Originally in your fiddle, you were transforming it very awkwardly and had too many styles, in my opinion, so the techniques in this JSfiddle should help: http://jsfiddle.net/NAy2r
Explained fiddle
So basically the front content exists in the container div, while the back content exists in the back div, which exists inside the container div. This is very similar to Apple's HTML5 Card flip demo, however there is a twist when it comes to backface-visibility
.
At the time that Apple relased that demo, backface-visibiity
didn't work on Chrome or Firefox. Chrome had some concept of perspective, but none of backface-visibility
, so when you flipped an element, you'd still see through to the back and the content of the back would show through both sides as well; However on Safari, it'd be perfect because it initially understood these concepts.
In further updates of Chrome in the months afterwards, Chrome understood the property, however it was applied literally and the back was hidden completely, regardless if you flipped it or not! What would be the point of having this property if it was going to hide the back completely no matter what? You could just apply display:none
, etc, to show the back if you wanted!!
And that is where IE stands as of today, it as well doesn't recognize the 'back' of the element (an element with transform:rotateY(180deg)
is considered to be the backside) like other modern browsers do. So when the element is flipped, backface-visibilty: hidden
is taken literally as it was in Chrome!
So this fiddle listens on an AnimationStart event on the container div, and on the animation start, it finds the duration of the animation and it uses that to calculate halfway though the animation, so when the animation is halfway, it changes backface-visibility
to visible
, that way the animation smoothly transitions like it's supposed to.
This was a pain to develop, IE10 is somewhat inconsistent, as it needs time to process it the first time (probably the jQuery). Notice the relief, lack of headache and fiery red eyes. The air around you has become cooler and you can finally breathe, because now you're not alone.
Edit: I forgot to add, that if your animation or transition has a different timing, the timing in this script will have to be adjusted, as it only works with linear transitions, as of now...
Very strange bug with box-shadow, perspective, overflow and backface-visibility: hidden in Google Chrome
Seems to be fixed in newer versions of Chrome.
Overflow hidden and child's backface visibility goes crazy
i had a hard time fixing your code, i also found some duplicate properties, so i decided to rewrite it from scratch since i think i got what you want to achieve.
basically you dont need to go from 360 to 180 you can just go from 180 to 0 and if you need another rotation from 0 to -180 ;)
when you put the same class which has a 180deg rotation on parent and child divs like this:
<article class="flip fliped anim" style="min-height: 308px;">
<article class="settings fliped">
.fliped {
-webkit-transform: rotateY(180deg);}
what you got is the sum of degrees, that is 360 which equals to 0! also you don't always have to specificate when a div is at 0deg since this is by default.
so here is the code i wrote, the animation triggers on hover (i commented the class involved in this).
i also added another wrapper to keep the perspective more realistic, if you dont like it just delete the very first class.
if you want to see the static backface only (as you asked) you just have to add the .hover
class to the .flip-container
div without messing with your css, like this:
<div class="flip-container hover" >
EDIT
i forgot about the overflow issue which is easily solved by applying the overflow:hidden;
property directly to the last single container of your markup. in my case directly to .front
or .back
divs (or both). here is the final Fiddle updated for your needs.
background-clip: text and backface-visibility: hidden not working as per Can I Use
Both background-clip
and backface-visibility
work in all major browsers. The problem is that browsers such as Chrome require the -webkit
prefix, whereas browsers such as Firefox merely support it.
As such, you want -webkit-background-clip: text
in addition to the regular background-clip: text
, and -webkit-backface-visibility: hidden
in addition to backface-visibility: hidden
. The former will work for Webkit browsers (like Chrome), and the latter will work with Firefox.
The following will work in both Chrome and Firefox:
p { margin: 1em 0; padding: 1.4em; background: linear-gradient(60deg, red, yellow, red, yellow, red); font: 900 1.2em sans-serif; text-decoration: underline;}
.text { background-clip: text; -webkit-background-clip: text; color: rgba(0, 0, 0, .2);}
.hidden { transform: rotateY(180deg); -webkit-transform: rotateY(180deg); backface-visibility: hidden; -webkit-backface-visibility: hidden;}
<p class="text">The background is clipped to the foreground text.</p><p class="hidden">HIDDEN</p>
Related Topics
Css3 ::Selection Behaves Differently in Ff & Chrome
CSS for Star Ratings via Fontawesome
Zoom Control and Streetview Not Showing on My Google Map
Css: Are View Height (Vh) and View Width (Vw) Units Widely Supported
Less Lists as a Mixin Argument(S)
How to Extend a Class/Mixin Which Has Dynamically Formed Selector
Can You Target an Element with CSS Only If 2 Classes Are Present
Vertically Center Items with Flexbox
How to Combine Two Media Queries
How to Make Firefox Print a Background-Color Style
Bootstrap 3: Pull-Right for Col-Lg Only
Selenium Webdriver Get Text from CSS Property "Content" on a ::Before Pseudo Element
Calc() Not Working Within Media Queries
Why Doesn't This CSS :Not() Declaration Filter Down