I have created a flip board animation with CSS transitions, and it works fine in Chrome/Firefox/Edge, but in Safari it flickers a lot during the transition, but the final state is correct.
I thought it might be a problem with the z-index in the transitions, but when removing those the flickering is still there.
I have autoprefixer on so I don't think it's an issue with backface-visibility.
If you look at this codepen in both Chrome and Safari, you can see the how it's supposed to be in Chrome, and the flickering issue in Safari.
https://codepen.io/joel-udd/pen/QWpEQMM
<div class="board board-1">
<div class="row-1">
<div class="letter-wrapper">
<div class="behind-letter">
<div class="behind bottom"><span>F</span></div>
<div class="behind top">I</div>
</div>
<div class="letter">
<div class="flip front">H</div>
<div class="flip back"><span>I</span></div>
</div>
<div class="letter">
<div class="flip front">G</div>
<div class="flip back"><span>H</span></div>
</div>
<div class="letter">
<div class="flip front">F</div>
<div class="flip back"><span>G</span></div>
</div>
</div>
</div>
</div>
.board {
display: inline-block;
position: relative;
perspective: 1000px;
.letter-wrapper {
display: inline-block;
position: relative;
width: 11vw;
margin-left: 2px;
height: 14vw;
.flip, .behind {
overflow: hidden;
position: absolute;
top: 0;
left: 0;
width: 100%;
font-size: 14vw;
span {
display: inline-block;
transform: translateY(-50%);
}
}
.letter {
display: inline-block;
position: absolute;
top: 2px;
width: 100%;
height: 7vw;
transform: rotateX(0);
transform-style: preserve-3d;
transform-origin: bottom center;
.flip {
height: 100%;
backface-visibility: hidden;
&.back {
transform: rotateX(180deg);
}
}
&:nth-child(2) {
z-index: 10;
}
&:nth-child(3) {
z-index: 20;
}
&:nth-child(4) {
z-index: 30;
}
}
.behind-letter {
display: inline-block;
position: absolute;
width: 100%;
height: 100%;
z-index: 5;
.behind {
height: 50%;
&.bottom {
top: calc(50% + 2px);
}
}
}
}
&.active {
.row-1 {
.letter-wrapper {
.letter {
transform: rotateX(-180deg);
&:nth-child(2) {
z-index: 50;
transition: transform .5s .5s, z-index 0s .6s;
}
&:nth-child(3) {
z-index: 40;
transition: transform .5s .3s, z-index 0s .4s;
}
&:nth-child(4) {
transition: transform .5s .1s;
}
}
}
}
}
}
Thanks!
I have a simple scaling animation applied to a circle using keyframes.
There is an unexpected and undesirable line that scales with the circle in Chrome Version 85.0.4183.102 (Official Build) (64-bit) and not in Firefox or Safari.
I cannot remove it - do you know how to? I have tried adding border: 0 to the various divs unsuccessfully.
#parent { overflow: hidden; background: #F0F4FF; height: 500px; width: 100%; position: relative; user-select: none; margin-block-end: 5rem; z-index: 3; }
.child { width: 100%; height: 100%; }
.child .inner { background: radial-gradient(circle at center, #D90368 20%, #F0F4FF 20%); }
.inner { position: relative; left: 0; top: 0; animation: circle 2s linear infinite; display: block; height:100%; width: 100%; content: " "; }
#keyframes circle { 0% { transform: scale(0.5) } 50% { transform: scale(1.2) } 80% { transform: scale(0.95) } 100% { transform: scale(1.0) } }
<div id='parent'>
<div class='child'>
<span class='inner'></span>
</div>
</div>
I have tried to search SO however I find a lot of similar line / scale / keyframe posts but these are intentional line animation posts.
I had the line to on Chrome. So I edited the code a bit, and the line was gone. Not sure what the problem was, just a different solution:
The html:
<div id="parent">
<div class="child">
<div class="inner"></div>
</div>
</div>
And the CSS
#parent {
overflow: hidden;
background: #f0f4ff;
height: 500px;
width: 100%;
position: relative;
user-select: none;
margin-block-end: 5rem;
z-index: 3;
}
.child {
width: 100%;
height: 100%;
position: relative;
}
.inner {
background-color: #d90368;
width: 10rem;
height: 10rem;
position: absolute;
left: calc(50% - 5rem);
top: calc(50% - 5rem);
animation: circle 2s linear infinite;
display: block;
content: " ";
border-radius: 50%;
}
#keyframes circle {
0% {
transform: scale(0.5);
}
50% {
transform: scale(1.2);
}
80% {
transform: scale(0.95);
}
100% {
transform: scale(1);
}
}
I'm struggling with centering the modal together with fade in and scale up:
$('#md-trigger').on('click', function(e) {
$('#modal-1').toggleClass("md-show"); //you can list several class names
e.preventDefault();
});
$('#md-close').on('click', function(e) {
$('#modal-1').toggleClass("md-show"); //you can list several class names
e.preventDefault();
});
.md-modal {
width: 100%;
max-width: 550px;
top: 50%;
left: 50%;
transform: translate(-50%,-50%);
position: absolute;
z-index: 9999;
visibility: hidden;
padding: 25px;
border: 1px solid rgba(0,0,0,.2);
border-radius: .3rem;
background-color: #fff;
font-family: Helvetica Neue,Helvetica,Arial,sans-serif;
box-shadow: 0 4px 8px 0 rgba(0,0,0,.2),0 6px 20px 0 rgba(0,0,0,.19);
outline: 0;
}
.md-show {
visibility: visible;
}
.md-overlay {
position: fixed;
width: 100%;
height: 100%;
visibility: hidden;
top: 0;
left: 0;
z-index: 9998;
opacity: 0;
background: rgba(40,43,49,.8);
-webkit-transition: all 0.3s;
transition: all 0.3s;
}
.md-show ~ .md-overlay {
opacity: 1;
visibility: visible;
}
.md-content {
color: #333;
}
.md-effect-1 {
-webkit-transform: scale(0.7);
-ms-transform: scale(0.7);
transform: scale(0.7);
opacity: 0;
-webkit-transition: all 0.3s;
transition: all 0.3s;
}
.md-show.md-effect-1 {
-webkit-transform: scale(1);
-ms-transform: scale(1);
transform: scale(1);
opacity: 1;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<button id="md-trigger">Show</button>
<div class="md-modal md-effect-1" id="modal-1">
<div class="md-content">
<h3>Modal Dialog</h3>
<p>This is a modal window. You can do the following things with it:</p>
<button class="md-close" id="md-close">Close me!</button>
</div>
</div>
<div class="md-overlay"></div>
The absolute positioning approach with transform:translate(-50%,-50%); isn't working for me. It has to be responsive so I can't use the margin-left approach. Do you have an idea why it is simply not displayed in the middle?
Please try this,
Add this style to md-modal-wrapper class. added a md-modal-wrapper div to cover md-modal class
.md-modal-wrapper{
width:100vw;
height:100vh;
display: flex;
justify-content: center;
align-items: center;
}
Remove this style
.md-modal {
top: 50%;
left: 50%;
transform: translate(-50%,-50%);
position: absolute;
}
$('#md-trigger').on('click', function(e) {
$('#modal-1').toggleClass("md-show"); //you can list several class names
e.preventDefault();
});
$('#md-close').on('click', function(e) {
$('#modal-1').toggleClass("md-show"); //you can list several class names
e.preventDefault();
});
.md-modal {
width:100%;
max-width: 550px;
z-index: 9999;
visibility: hidden;
padding: 25px;
border: 1px solid rgba(0,0,0,.2);
border-radius: .3rem;
background-color: #fff;
font-family: Helvetica Neue,Helvetica,Arial,sans-serif;
box-shadow: 0 4px 8px 0 rgba(0,0,0,.2),0 6px 20px 0 rgba(0,0,0,.19);
outline: 0;
}
.md-show {
visibility: visible;
}
.md-overlay {
position: fixed;
width: 100%;
height: 100%;
visibility: hidden;
top: 0;
left: 0;
z-index: 9998;
opacity: 0;
background: rgba(40,43,49,.8);
-webkit-transition: all 0.3s;
transition: all 0.3s;
}
.md-show ~ .md-overlay {
opacity: 1;
visibility: visible;
}
.md-content {
color: #333;
}
.md-effect-1 {
-webkit-transform: scale(0.7);
-ms-transform: scale(0.7);
transform: scale(0.7);
opacity: 0;
-webkit-transition: all 0.3s;
transition: all 0.3s;
}
.md-show.md-effect-1 {
-webkit-transform: scale(1);
-ms-transform: scale(1);
transform: scale(1);
opacity: 1;
}
.md-modal-wrapper{
width:100vw;
height:100vh;
display: flex;
justify-content: center;
align-items: center;
}
body{
margin:0;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<body>
<button id="md-trigger">Show</button>
<div class="md-modal-wrapper">
<div class="md-modal md-effect-1" id="modal-1">
<div class="md-content">
<h3>Modal Dialog</h3>
<p>This is a modal window. You can do the following things with it:</p>
<button class="md-close" id="md-close">Close me!</button>
</div>
</div>
<div class="md-overlay"></div>
</div>
</body>
scale(1) was overriding the other transform property, translate(-50%,-50%).
It can be easily fixed by combining them both: transform: translate(-50%,-50%) scale(1).
$('#md-trigger').on('click', function(e) {
$('#modal-1').toggleClass("md-show"); //you can list several class names
e.preventDefault();
});
$('#md-close').on('click', function(e) {
$('#modal-1').toggleClass("md-show"); //you can list several class names
e.preventDefault();
});
.md-modal {
width: 100%;
max-width: 550px;
top: 50%;
left: 50%;
transform: translate(-50%,-50%);
position: absolute;
z-index: 9999;
visibility: hidden;
padding: 25px;
border: 1px solid rgba(0,0,0,.2);
border-radius: .3rem;
background-color: #fff;
font-family: Helvetica Neue,Helvetica,Arial,sans-serif;
box-shadow: 0 4px 8px 0 rgba(0,0,0,.2),0 6px 20px 0 rgba(0,0,0,.19);
outline: 0;
}
.md-show {
visibility: visible;
}
.md-overlay {
position: fixed;
width: 100%;
height: 100%;
visibility: hidden;
top: 0;
left: 0;
z-index: 9998;
opacity: 0;
background: rgba(40,43,49,.8);
-webkit-transition: all 0.3s;
transition: all 0.3s;
}
.md-show ~ .md-overlay {
opacity: 1;
visibility: visible;
}
.md-content {
color: #333;
}
.md-effect-1 {
-webkit-transform: scale(0.7);
-ms-transform: scale(0.7);
transform: scale(0.7);
opacity: 0;
-webkit-transition: all 0.3s;
transition: all 0.3s;
}
.md-show.md-effect-1 {
-webkit-transform: scale(1);
-ms-transform: scale(1);
transform: translate(-50%,-50%) scale(1);
opacity: 1;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<button id="md-trigger">Show</button>
<div class="md-modal md-effect-1" id="modal-1">
<div class="md-content">
<h3>Modal Dialog</h3>
<p>This is a modal window. You can do the following things with it:</p>
<button class="md-close" id="md-close">Close me!</button>
</div>
</div>
<div class="md-overlay"></div>
How about using flex?
Remove position: absolute; and transform: translate(-50%,-50%); from md-modal
and cover the modal with flex div
.md-container {
display:flex;
justify-content:center;
align-items:center
}
<div class="md-container">
<div class="md-modal">
~~
</div>
</div>
I don't know how to use snippet so I'm attaching a codePen link 😂
https://codepen.io/seongmin0801/pen/MWyrYvm
Make transform: translate(-50%,-50%) !important;. There is .md-show.md-effect-1 { transform: scale(1); } that overrides it that's why you should use important
I am using this radio button effect - https://codepen.io/tomma5o/pen/grJyzL/ which works OK, but now I ran into problem where a few of my options are longer text and it goes over bottom option (because there is 30px height on li).
Here is example - https://codepen.io/BrixyX/pen/OJMwjrN. Is there any easy fix for this, because whatever I try, I mess up the effect?
#import url(https://fonts.googleapis.com/css?family=Roboto:400,300,500,700);
::selection {
background: none;
}
body {
background: #BADA55;
font-family: 'Roboto';
font-weight: 500;
text-transform: uppercase;
color: #2E8612;
overflow: hidden;
height: 100%;
}
h1 {
font-weight: 100;
text-align: center;
margin: 0;
padding: 0;
font-size: 50px;
}
h4 {
font-weight: 400;
text-align: center;
margin: 0;
padding: 0;
margin-bottom: 50px;
}
.continput {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
margin: auto;
width: 500px;
height: 270px;
padding: 16px;
box-sizing: border-box;
}
ul {
list-style-type: none;
width: 220px;
margin: auto;
}
li {
position: relative;
padding: 10px;
padding-left: 40px;
height: 30px;
}
label:before {
content: "";
width: 15px;
height: 15px;
background: #fff;
position: absolute;
left: 7px;
top: calc(50% - 13px);
box-sizing: border-box;
border-radius: 50%;
}
input[type="radio"] {
opacity: 0;
-webkit-appearance: none;
display: inline-block;
vertical-align: middle;
z-index: 100;
margin: 0;
padding: 0;
width: 100%;
height: 30px;
position: absolute;
left: 0;
top: calc(50% - 15px);
cursor: pointer;
}
.bullet {
position: relative;
width: 25px;
height: 25px;
left: -3px;
top: 2px;
border: 5px solid #fff;
opacity: 0;
border-radius: 50%;
}
input[type="radio"]:checked~.bullet {
position: absolute;
opacity: 1;
animation-name: explode;
animation-duration: 0.350s;
}
.line {
position: absolute;
width: 10px;
height: 2px;
background-color: #fff;
opacity: 0;
}
.line.zero {
left: 11px;
top: -21px;
transform: translateY(20px);
width: 2px;
height: 10px;
}
.line.one {
right: -7px;
top: -11px;
transform: rotate(-55deg) translate(-9px);
}
.line.two {
right: -20px;
top: 11px;
transform: translate(-9px);
}
.line.three {
right: -8px;
top: 35px;
transform: rotate(55deg) translate(-9px);
}
.line.four {
left: -8px;
top: -11px;
transform: rotate(55deg) translate(9px);
}
.line.five {
left: -20px;
top: 11px;
transform: translate(9px);
}
.line.six {
left: -8px;
top: 35px;
transform: rotate(-55deg) translate(9px);
}
.line.seven {
left: 11px;
bottom: -21px;
transform: translateY(-20px);
width: 2px;
height: 10px;
}
input[type="radio"]:checked~.bullet .line.zero {
animation-name: drop-zero;
animation-delay: 0.100s;
animation-duration: 0.9s;
animation-fill-mode: forwards;
}
input[type="radio"]:checked~.bullet .line.one {
animation-name: drop-one;
animation-delay: 0.100s;
animation-duration: 0.9s;
animation-fill-mode: forwards;
}
input[type="radio"]:checked~.bullet .line.two {
animation-name: drop-two;
animation-delay: 0.100s;
animation-duration: 0.9s;
animation-fill-mode: forwards;
}
input[type="radio"]:checked~.bullet .line.three {
animation-name: drop-three;
animation-delay: 0.100s;
animation-duration: 0.9s;
animation-fill-mode: forwards;
}
input[type="radio"]:checked~.bullet .line.four {
animation-name: drop-four;
animation-delay: 0.100s;
animation-duration: 0.9s;
animation-fill-mode: forwards;
}
input[type="radio"]:checked~.bullet .line.five {
animation-name: drop-five;
animation-delay: 0.100s;
animation-duration: 0.9s;
animation-fill-mode: forwards;
}
input[type="radio"]:checked~.bullet .line.six {
animation-name: drop-six;
animation-delay: 0.100s;
animation-duration: 0.9s;
animation-fill-mode: forwards;
}
input[type="radio"]:checked~.bullet .line.seven {
animation-name: drop-seven;
animation-delay: 0.100s;
animation-duration: 0.9s;
animation-fill-mode: forwards;
}
#keyframes explode {
0% {
opacity: 0;
transform: scale(10);
}
60% {
opacity: 1;
transform: scale(0.5);
}
100% {
opacity: 1;
transform: scale(1);
}
}
#keyframes drop-zero {
0% {
opacity: 0;
transform: translateY(20px);
height: 10px;
}
20% {
opacity: 1;
}
100% {
transform: translateY(-2px);
height: 0px;
opacity: 0;
}
}
#keyframes drop-one {
0% {
opacity: 0;
transform: rotate(-55deg) translate(-20px);
width: 10px;
}
20% {
opacity: 1;
}
100% {
transform: rotate(-55deg) translate(9px);
width: 0px;
opacity: 0;
}
}
#keyframes drop-two {
0% {
opacity: 0;
transform: translate(-20px);
width: 10px;
}
20% {
opacity: 1;
}
100% {
transform: translate(9px);
width: 0px;
opacity: 0;
}
}
#keyframes drop-three {
0% {
opacity: 0;
transform: rotate(55deg) translate(-20px);
width: 10px;
}
20% {
opacity: 1;
}
100% {
transform: rotate(55deg) translate(9px);
width: 0px;
opacity: 0;
}
}
#keyframes drop-four {
0% {
opacity: 0;
transform: rotate(55deg) translate(20px);
width: 10px;
}
20% {
opacity: 1;
}
100% {
transform: rotate(55deg) translate(-9px);
width: 0px;
opacity: 0;
}
}
#keyframes drop-five {
0% {
opacity: 0;
transform: translate(20px);
width: 10px;
}
20% {
opacity: 1;
}
100% {
transform: translate(-9px);
width: 0px;
opacity: 0;
}
}
#keyframes drop-six {
0% {
opacity: 0;
transform: rotate(-55deg) translate(20px);
width: 10px;
}
20% {
opacity: 1;
}
100% {
transform: rotate(-55deg) translate(-9px);
width: 0px;
opacity: 0;
}
}
#keyframes drop-seven {
0% {
opacity: 0;
transform: translateY(-20px);
height: 10px;
}
20% {
opacity: 1;
}
100% {
transform: translateY(2px);
height: 0px;
opacity: 0;
}
}
<div class="continput">
<h1>Jelly Radio btn</h1>
<h4>I hope you enjoyed it</h4>
<ul>
<li>
<input checked type="radio" name="1">
<label>OMG a radio! Longer option text Longer option text Longer option text Longer option text Longer option text Longer option text Longer option text Longer option ...</label>
<div class="bullet">
<div class="line zero"></div>
<div class="line one"></div>
<div class="line two"></div>
<div class="line three"></div>
<div class="line four"></div>
<div class="line five"></div>
<div class="line six"></div>
<div class="line seven"></div>
</div>
</li>
<li>
<input type="radio" name="1">
<label>Uuuuh radio</label>
<div class="bullet">
<div class="line zero"></div>
<div class="line one"></div>
<div class="line two"></div>
<div class="line three"></div>
<div class="line four"></div>
<div class="line five"></div>
<div class="line six"></div>
<div class="line seven"></div>
</div>
</li>
<li>
<input type="radio" name="1">
<label>radio everywhere</label>
<div class="bullet">
<div class="line zero"></div>
<div class="line one"></div>
<div class="line two"></div>
<div class="line three"></div>
<div class="line four"></div>
<div class="line five"></div>
<div class="line six"></div>
<div class="line seven"></div>
</div>
</li>
</ul>
</div>
I have cleaned up a few things and created a new fiddle from your pen here.
Firstly, I've tried removing the absolute positioning being used in a lot of places.
I've also made use of the feature that the label element provides which is interaction with the input elements.
I've moved your radio elements inside the label and have also moved the bullet animation accordingly.
Overall, the label element is now being used as a wrapper for all your elements inside of it, and hence those elements would align themselves based on the size of their parent.
P.S., since I tried to wrap this up quickly, I've center-aligned the bullet inside your label using the translate(-50%) hack. There are other cleaner ways of doing this but this one was just a quicker way for now.
There are several ways available to fix the issue of long option texts covering the rest of the options.
The first option is to change the width of the continput class to a higher value so that more text can fit inside of the labels. The labels are being constrained by the margin and padding enabled by the list and list items the radio buttons are put inside of. Hence a wider width will mean that more option text can be neatly displayed.
The second option is to set the overflow property of the list items to hidden, like this (new property at the bottom of the definition):
li {
position: relative;
padding: 10px;
padding-left: 40px;
height: 30px;
overflow: hidden;
}
This way, text that cannot be displayed without overflowing from the list items will be hidden and not cover text belonging to radio buttons further down. There are also more options for the overflow setting; the Mozilla MDN web docs has a short article on the property: https://developer.mozilla.org/en-US/docs/Web/CSS/overflow
The third option is a combination of these options above. This should result in something that looks and works in a way that suits your needs. If you haven't started inspecting and experimenting with your own content using something like Google Chrome's Inspect function yet, I recommend you to read a tutorial for the browser you are using. Zapier has an in-depth tutorial for Google Chrome here and I see that Microsoft have incorporated the same tools that are available in Google Chrome into their updated Microsoft Edge (with the blue and green logo).
I want to disable transform in my child div. Here is fiddle. Is it possible to disable scale for class .image-text ?
.photo:hover{
transform: scale(1.4);
-moz-transform: scale(1.4);
-webkit-transform: scale(1.4);
-o-transform: scale(1.4);
-ms-transform: scale(1.4);
}
.photo:hover >*{
transform: none;
}
make a new child element and call your image on it.
here you can see http://jsfiddle.net/rajjuneja49/s3hWj/879/
May be you were looking for this....
You can see these example.
.element{
width: 400px;
height: 550px;
}
img {
max-width: 100%;
height: auto;
vertical-align: middle;
border: 0;
}
.main-photo-area {
position:relative;
display: block;
overflow: hidden;
}
.main-photo-area img.photo{
transition: all 0.3s ease;
width: 100%;
}
.main-photo-area:hover img.photo{
transform: scale(1.4);
}
.image-text {
background: rgba(34, 90, 159, 0.6);
bottom: 0;
color: white;
font-size: 1em;
left: 0;
opacity: 0;
overflow: hidden;
padding: 3em 3em 4.25em 3em;
position: absolute;
text-align: center;
top: 0;
right: 0;
-webkit-transition: 0.6s;
transition: 0.6s;
}
.image-text:hover {
opacity: 1;
}
<div class="element">
<div class="main-photo-area">
<img class="photo" src="http://heavytable.com/wp-content/uploads/2012/11/wine-glasses-650-325.jpg"/>
<a class="over" href="/szablon/?id=single">
<div class="image-text">
<h2>Titel</h2>
<p>Desc</p>
<span class="icon">Look</span>
</div>
</a>
</div>
</div>