I have a simple modal, which opens up upon :checked input. In Firefox and IE the transition animation works fine, but in Chrome it glitches (effect not smooth) when it shows up upon checking the input.
Demo fiddle: JsFiddle
When i remove visibility: hidden it works fine, but then the modal blocks the rest of the page under neath it - no text can be selected, no buttons clicked etc.
Any ideas on how to make the transition smooth in Chrome?
You declared transform: none; on your modal div. Just define a rotationX instead, so your animation has a starting and ending point. That solves the animation issue:
input#switch:checked ~ #test > div {
transform: rotateX(0deg);
}
http://jsfiddle.net/s8hts3v7/9/
#test {
position: fixed;
top: 0;
right: 0;
bottom: 0;
left: 0;
width: 100%;
height: 100%;
background: rgba(0,0,0,0.8);
z-index: 9999999;
visibility: hidden;
}
input#switch:checked ~ #test {
visibility: visible;
}
#test > div {
background: #fff;
width: 300px;
height: 100px;
padding: 30px;
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
margin: auto;
transform: perspective(300px) rotateX(-90deg);
transform-origin: top center;
transition: 0.4s ease;
}
input#switch:checked ~ #test > div {
transform: rotateX(0deg);
}
#test > div label {
background: #000;
color: #fff;
display: block;
text-align: center;
padding: 8px;
margin-top: 20px;
cursor: pointer;
}
<input id="switch" type="checkbox" name="test-chkbox" />
<label for="switch">Open modal</label>
<div id="test">
<div>Lorem Ipsum is simply dummy text of the printing and typesetting industry.
<label for="switch">Close modal</label>
</div>
</div>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With