So here is my code...
I understand how to make the text disappear by making it transparent but i want it to stay gone after hovering over it so it doesnt come back - how do I accomplish this?
.disappear {
margin-top: 60px;
text-align: center;
transition: all 5s ease .3s;
font-family: Bungee Spice;
}
.disappear:hover {
color: transparent;
}
you need to use onmouseover and remove() like this
function bye() {
const dis = document.getElementById("dis");
dis.remove();
}
* {
padding: 0;
margin: 0;
/* border: 1px solid red; */
overflow-x: hidden;
}
div {
height: 50vh;
width: 100vw;
display: flex;
justify-content: center;
align-items: center;
font-size: xx-large;
overflow: auto;
background: lightblue;
}
<div class="div">
<h2 onmouseover="bye()" id="dis">will go on hover</h2>
</div>
I don't think it's possible to make it run smoothly with pure CSS, so far, this is what I think is close to what you want to accomplish. So before hover, the animation to make it gone is already set, but the animation is not running yet, the animation will run only if the element is hovered. The problem here is that when it's hovered then it's unhovered before it's gone, the element will be half gone as the animation is paused.
.container {
width: 100%;
height: 800px;
background: #dddddd;
}
.disappear {
margin-top: 60px;
text-align: center;
font-family: Bungee Spice;
background: yellow;
animation: example 5s linear forwards;
animation-play-state: paused;
}
.disappear:hover {
animation-play-state: running;
}
#keyframes example {
from {opacity: 1}
to {opacity: 0}
}
<div class="container">
not disappear
<div class="disappear">
DISAPPEAR
</div>
</div>
The better way would be to use javascript and use onmouseover to add the animation instead of using :hover, the difference is that when you onmouseout, the function is still executed (the animation persists). This is with JS:
function fade(elm) {
elm.style.animation = "example 5s linear forwards";
}
.container {
width: 100%;
height: 800px;
background: #dddddd;
}
.disappear {
margin-top: 60px;
text-align: center;
font-family: Bungee Spice;
background: yellow;
}
#keyframes example {
from {
opacity: 1
}
to {
opacity: 0
}
}
<div class="container">
not disappear
<div class="disappear" onmouseover="fade(this)">
DISAPPEAR
</div>
</div>
i think everything all ok but stil not working...
ff - ok
edge, opera, more - not working good (adds a pause at the end ... sometimes skips the last few frames)
#box{
overflow: hidden;
width: 416px;
height: 416px;
margin: 0px;
padding: 0px;
display: inline-block;
border: 0px;
font-size: 0px;
letter-spacing: 0px;
word-spacing: 0px;
}
#tlo{
width: 12064px;
height: 416px;
background-image:
url('https://serwer1816342.home.pl/nowa2021/portfolio/czolowka/czolowka00.jpg'), url('https://serwer1816342.home.pl/nowa2021/portfolio/czolowka/czolowka01.jpg'), url('https://serwer1816342.home.pl/nowa2021/portfolio/czolowka/czolowka02.jpg'), url('https://serwer1816342.home.pl/nowa2021/portfolio/czolowka/czolowka03.jpg'), url('https://serwer1816342.home.pl/nowa2021/portfolio/czolowka/czolowka04.jpg'), url('https://serwer1816342.home.pl/nowa2021/portfolio/czolowka/czolowka05.jpg'), url('https://serwer1816342.home.pl/nowa2021/portfolio/czolowka/czolowka06.jpg'), url('https://serwer1816342.home.pl/nowa2021/portfolio/czolowka/czolowka07.jpg'), url('https://serwer1816342.home.pl/nowa2021/portfolio/czolowka/czolowka10.jpg'), url('https://serwer1816342.home.pl/nowa2021/portfolio/czolowka/czolowka11.jpg'), url('https://serwer1816342.home.pl/nowa2021/portfolio/czolowka/czolowka14.jpg'), url('https://serwer1816342.home.pl/nowa2021/portfolio/czolowka/czolowka15.jpg'), url('https://serwer1816342.home.pl/nowa2021/portfolio/czolowka/czolowka16.jpg'), url('https://serwer1816342.home.pl/nowa2021/portfolio/czolowka/czolowka17.jpg'), url('https://serwer1816342.home.pl/nowa2021/portfolio/czolowka/czolowka18.jpg'), url('https://serwer1816342.home.pl/nowa2021/portfolio/czolowka/czolowka19.jpg'), url('https://serwer1816342.home.pl/nowa2021/portfolio/czolowka/czolowka20.jpg'), url('https://serwer1816342.home.pl/nowa2021/portfolio/czolowka/czolowka21.jpg'), url('https://serwer1816342.home.pl/nowa2021/portfolio/czolowka/czolowka22.jpg'), url('https://serwer1816342.home.pl/nowa2021/portfolio/czolowka/czolowka23.jpg'), url('https://serwer1816342.home.pl/nowa2021/portfolio/czolowka/czolowka24.jpg'), url('https://serwer1816342.home.pl/nowa2021/portfolio/czolowka/czolowka25.jpg'), url('https://serwer1816342.home.pl/nowa2021/portfolio/czolowka/czolowka26.jpg'), url('https://serwer1816342.home.pl/nowa2021/portfolio/czolowka/czolowka27.jpg'), url('https://serwer1816342.home.pl/nowa2021/portfolio/czolowka/czolowka28.jpg');
background-repeat: no-repeat;
background-position: 0px, 416px, 832px, 1248px, 1664px, 2080px, 2496px, 2912px, 3328px, 3744px, 4160px, 4576px, 4992px, 5408px, 5824px, 6240px, 6656px, 7072px, 7488px, 7904px, 8320px, 8736px, 9152px, 9568px, 9984px, 10400px, 10816px, 11232px, 11648px;
position: relative;
left: 0;
top: 0;
}
#tlo:hover{
animation-name: tlo-tumb-animacja;
animation-duration: 1s;
animation-timing-function: steps(28);
animation-iteration-count: infinite;
}
#keyframes tlo-tumb-animacja {
from {transform: translateX(0);}
to {transform: translateX(-96.55172414%);}
}
<h2>everyimages:</h2><br>
<div id="box1">
<div id="tlo">
</div>
</div>
<h2>animation:</h2>
<div id="box">
<div id="tlo">
</div>
</div>
does it take some time to return to position zero ... more than one frame?
is the number of elements translated into div's length a problem?
where is the mistake? browsers (console) say everything is ok ... no bugs ...
Codepen
One way round this 'flashing' problem is to have two complete copies of the background images.
Then just have half the number of steps and translate to -50% instead of -100%.
This helps because the whole thing repositions itself but to the same visual effect as when it's 50% translated so there is no jump.
Just for demo I've cut it in half so there are 14 steps (so I didn't copy the background again) but of course you'll want to put all your 28 images in twice for the real use.
* {
margin: 0;
}
#box{
overflow: hidden;
width: 416px;
height: 416px;
margin: 0px;
padding: 0px;
display: inline-block;
border: 0px;
font-size: 0px;
letter-spacing: 0px;
word-spacing: 0px;
}
#tlo{
width: 12064px;
height: 416px;
background-image:
url('https://serwer1816342.home.pl/nowa2021/portfolio/czolowka/czolowka00.jpg'), url('https://serwer1816342.home.pl/nowa2021/portfolio/czolowka/czolowka01.jpg'), url('https://serwer1816342.home.pl/nowa2021/portfolio/czolowka/czolowka02.jpg'), url('https://serwer1816342.home.pl/nowa2021/portfolio/czolowka/czolowka03.jpg'), url('https://serwer1816342.home.pl/nowa2021/portfolio/czolowka/czolowka04.jpg'), url('https://serwer1816342.home.pl/nowa2021/portfolio/czolowka/czolowka05.jpg'), url('https://serwer1816342.home.pl/nowa2021/portfolio/czolowka/czolowka06.jpg'), url('https://serwer1816342.home.pl/nowa2021/portfolio/czolowka/czolowka07.jpg'), url('https://serwer1816342.home.pl/nowa2021/portfolio/czolowka/czolowka10.jpg'), url('https://serwer1816342.home.pl/nowa2021/portfolio/czolowka/czolowka11.jpg'), url('https://serwer1816342.home.pl/nowa2021/portfolio/czolowka/czolowka14.jpg'), url('https://serwer1816342.home.pl/nowa2021/portfolio/czolowka/czolowka15.jpg'), url('https://serwer1816342.home.pl/nowa2021/portfolio/czolowka/czolowka16.jpg'), url('https://serwer1816342.home.pl/nowa2021/portfolio/czolowka/czolowka17.jpg'), url('https://serwer1816342.home.pl/nowa2021/portfolio/czolowka/czolowka18.jpg'), url('https://serwer1816342.home.pl/nowa2021/portfolio/czolowka/czolowka19.jpg'), url('https://serwer1816342.home.pl/nowa2021/portfolio/czolowka/czolowka20.jpg'), url('https://serwer1816342.home.pl/nowa2021/portfolio/czolowka/czolowka21.jpg'), url('https://serwer1816342.home.pl/nowa2021/portfolio/czolowka/czolowka22.jpg'), url('https://serwer1816342.home.pl/nowa2021/portfolio/czolowka/czolowka23.jpg'), url('https://serwer1816342.home.pl/nowa2021/portfolio/czolowka/czolowka24.jpg'), url('https://serwer1816342.home.pl/nowa2021/portfolio/czolowka/czolowka25.jpg'), url('https://serwer1816342.home.pl/nowa2021/portfolio/czolowka/czolowka26.jpg'), url('https://serwer1816342.home.pl/nowa2021/portfolio/czolowka/czolowka27.jpg'), url('https://serwer1816342.home.pl/nowa2021/portfolio/czolowka/czolowka28.jpg');
background-repeat: no-repeat;
background-position: 0px, 416px, 832px, 1248px, 1664px, 2080px, 2496px, 2912px, 3328px, 3744px, 4160px, 4576px, 4992px, 5408px, 5824px, 6240px, 6656px, 7072px, 7488px, 7904px, 8320px, 8736px, 9152px, 9568px, 9984px, 10400px, 10816px, 11232px, 11648px;
position: relative;
left: 0;
top: 0;
}
#tlo:hover{
animation-name: tlo-tumb-animacja;
animation-duration: 1s;
animation-timing-function: steps(14);
animation-iteration-count: infinite;
}
#keyframes tlo-tumb-animacja {
from {transform: translateX(0);}
to {transform: translateX(-50%);}
}
<h2>everyimages:</h2><br>
<div id="box1">
<div id="tlo">
</div>
</div>
<h2>animation:</h2>
<div id="box">
<div id="tlo">
</div>
</div>
still working ... add preload for css like Preloading CSS Images
... did not help
but now I see - #box with css {overflow: hidden; & more} have problem ...
#box1 without css works fine
when i use 8 pic> all alright ... 29> problem ... too long div? no - #box1 works!
body::after{
position:absolute; width:0; height:0; overflow:hidden; z-index:-1;
content:url('https://serwer1816342.home.pl/nowa2021/portfolio/czolowka/czolowka00.jpg')
url('https://serwer1816342.home.pl/nowa2021/portfolio/czolowka/czolowka01.jpg')
url('https://serwer1816342.home.pl/nowa2021/portfolio/czolowka/czolowka02.jpg')
url('https://serwer1816342.home.pl/nowa2021/portfolio/czolowka/czolowka03.jpg')
url('https://serwer1816342.home.pl/nowa2021/portfolio/czolowka/czolowka04.jpg')
url('https://serwer1816342.home.pl/nowa2021/portfolio/czolowka/czolowka05.jpg')
url('https://serwer1816342.home.pl/nowa2021/portfolio/czolowka/czolowka06.jpg')
url('https://serwer1816342.home.pl/nowa2021/portfolio/czolowka/czolowka07.jpg')
url('https://serwer1816342.home.pl/nowa2021/portfolio/czolowka/czolowka08.jpg')
url('https://serwer1816342.home.pl/nowa2021/portfolio/czolowka/czolowka09.jpg')
url('https://serwer1816342.home.pl/nowa2021/portfolio/czolowka/czolowka10.jpg')
url('https://serwer1816342.home.pl/nowa2021/portfolio/czolowka/czolowka11.jpg')
url('https://serwer1816342.home.pl/nowa2021/portfolio/czolowka/czolowka12.jpg')
url('https://serwer1816342.home.pl/nowa2021/portfolio/czolowka/czolowka13.jpg')
url('https://serwer1816342.home.pl/nowa2021/portfolio/czolowka/czolowka14.jpg')
url('https://serwer1816342.home.pl/nowa2021/portfolio/czolowka/czolowka15.jpg')
url('https://serwer1816342.home.pl/nowa2021/portfolio/czolowka/czolowka16.jpg')
url('https://serwer1816342.home.pl/nowa2021/portfolio/czolowka/czolowka17.jpg')
url('https://serwer1816342.home.pl/nowa2021/portfolio/czolowka/czolowka18.jpg')
url('https://serwer1816342.home.pl/nowa2021/portfolio/czolowka/czolowka19.jpg')
url('https://serwer1816342.home.pl/nowa2021/portfolio/czolowka/czolowka20.jpg')
url('https://serwer1816342.home.pl/nowa2021/portfolio/czolowka/czolowka21.jpg')
url('https://serwer1816342.home.pl/nowa2021/portfolio/czolowka/czolowka22.jpg')
url('https://serwer1816342.home.pl/nowa2021/portfolio/czolowka/czolowka23.jpg')
url('https://serwer1816342.home.pl/nowa2021/portfolio/czolowka/czolowka24.jpg')
url('https://serwer1816342.home.pl/nowa2021/portfolio/czolowka/czolowka25.jpg')
url('https://serwer1816342.home.pl/nowa2021/portfolio/czolowka/czolowka26.jpg')
url('https://serwer1816342.home.pl/nowa2021/portfolio/czolowka/czolowka27.jpg')
url('https://serwer1816342.home.pl/nowa2021/portfolio/czolowka/czolowka28.jpg');
}
* {
margin: 0;
}
#box{
overflow: hidden;
width: 416px;
height: 416px;
margin: 0px;
padding: 0px;
display: block;
border: 0px;
font-size: 0px;
letter-spacing: 0px;
word-spacing: 0px;
}
#tlo{
width: 12064px;
height: 416px;
background-image:
url('https://serwer1816342.home.pl/nowa2021/portfolio/czolowka/czolowka00.jpg'),
url('https://serwer1816342.home.pl/nowa2021/portfolio/czolowka/czolowka01.jpg'),
url('https://serwer1816342.home.pl/nowa2021/portfolio/czolowka/czolowka02.jpg'),
url('https://serwer1816342.home.pl/nowa2021/portfolio/czolowka/czolowka03.jpg'),
url('https://serwer1816342.home.pl/nowa2021/portfolio/czolowka/czolowka04.jpg'),
url('https://serwer1816342.home.pl/nowa2021/portfolio/czolowka/czolowka05.jpg'),
url('https://serwer1816342.home.pl/nowa2021/portfolio/czolowka/czolowka06.jpg'),
url('https://serwer1816342.home.pl/nowa2021/portfolio/czolowka/czolowka07.jpg'),
url('https://serwer1816342.home.pl/nowa2021/portfolio/czolowka/czolowka08.jpg'),
url('https://serwer1816342.home.pl/nowa2021/portfolio/czolowka/czolowka09.jpg'),
url('https://serwer1816342.home.pl/nowa2021/portfolio/czolowka/czolowka10.jpg'),
url('https://serwer1816342.home.pl/nowa2021/portfolio/czolowka/czolowka11.jpg'),
url('https://serwer1816342.home.pl/nowa2021/portfolio/czolowka/czolowka12.jpg'),
url('https://serwer1816342.home.pl/nowa2021/portfolio/czolowka/czolowka13.jpg'),
url('https://serwer1816342.home.pl/nowa2021/portfolio/czolowka/czolowka14.jpg'),
url('https://serwer1816342.home.pl/nowa2021/portfolio/czolowka/czolowka15.jpg'),
url('https://serwer1816342.home.pl/nowa2021/portfolio/czolowka/czolowka16.jpg'),
url('https://serwer1816342.home.pl/nowa2021/portfolio/czolowka/czolowka17.jpg'),
url('https://serwer1816342.home.pl/nowa2021/portfolio/czolowka/czolowka18.jpg'),
url('https://serwer1816342.home.pl/nowa2021/portfolio/czolowka/czolowka19.jpg'),
url('https://serwer1816342.home.pl/nowa2021/portfolio/czolowka/czolowka20.jpg'),
url('https://serwer1816342.home.pl/nowa2021/portfolio/czolowka/czolowka21.jpg'),
url('https://serwer1816342.home.pl/nowa2021/portfolio/czolowka/czolowka22.jpg'),
url('https://serwer1816342.home.pl/nowa2021/portfolio/czolowka/czolowka23.jpg'),
url('https://serwer1816342.home.pl/nowa2021/portfolio/czolowka/czolowka24.jpg'),
url('https://serwer1816342.home.pl/nowa2021/portfolio/czolowka/czolowka25.jpg'),
url('https://serwer1816342.home.pl/nowa2021/portfolio/czolowka/czolowka26.jpg'),
url('https://serwer1816342.home.pl/nowa2021/portfolio/czolowka/czolowka27.jpg'),
url('https://serwer1816342.home.pl/nowa2021/portfolio/czolowka/czolowka28.jpg');
background-repeat: no-repeat;
background-position: 0px, 416px, 832px, 1248px, 1664px, 2080px, 2496px, 2912px, 3328px, 3744px, 4160px, 4576px, 4992px, 5408px, 5824px, 6240px, 6656px, 7072px, 7488px, 7904px, 8320px, 8736px, 9152px, 9568px, 9984px, 10400px, 10816px, 11232px, 11648px;
position: relative;
left: 0;
top: 0;
}
#tlo:hover{
animation-name: tlo-tumb-animacja;
animation-duration: 1s;
animation-timing-function: steps(29);
animation-iteration-count: infinite;
}
#keyframes tlo-tumb-animacja {
from {
transform: translateX(0);
}
to {
transform: translateX(-12064px);
}
}
<h2>animation:</h2>
<div id="box">
<div id="tlo">
</div>
</div>
<h2>everyimages:</h2><br>
<div id="box1">
<div id="tlo">
</div>
</div>
(Note: This was asked [exactly] 1½ years ago and had [exactly] zero activity... I'm apparently having the same issue so hopefully OP #Jaffa won't mind me piggybacking in it, and slapping a bounty on it to [hopefully] generate some interest!)
The OP's original question is below, and my added issue & examples is below that.
[Original Question:]
I am trying to animate a zoom out effect on an SVG. I have gotten it working, but the first frame, which is scaled to 30, is blurry/pixelated in Firefox.
Firefox:
Chrome:
I do not see the same issue in Chrome or Edge. The initial frame is crisp as I would expect being an SVG.
html,
body {
margin: 0px;
padding: 0px;
}
.wrapper {
padding: 50px 50px;
max-width: 1200px;
margin-left: auto;
margin-right: auto;
margin-top: 80px;
}
.img_zoom {
width: 400px;
height: 500px;
margin: 2em auto 2em auto;
overflow: hidden;
}
.zoom {
width: 100%;
height: 100%;
background-position: center;
background-size: cover;
animation: zoom 5s ease-in-out 4s 1 normal forwards;
transform: translate(3400px, -3600px) scale(30);
}
#keyframes zoom {
to {
margin-left: 0;
transform: translate(0px, 0px) scale(0.7);
}
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<div class="wrapper">
<div class="img_zoom">
<div class="zoom"><img src="https://flexion.tech/images/box-con.svg"></div>
</div>
</div>
</body>
</html>
Code pen is here for review:
https://codepen.io/jaffa80/pen/KKpxgeQ
Any ideas how I can fix the blurry issue in Firefox?
Another problem i am having is if I remove margin-left:0 from the #keyframe to, things stop working. Any pointers on this would be appreciated also.
EDIT:
I have a rounded div container containing several elements to position text within the circle. I need the circle to "grow" when the user gets to it, so I figured I'd use transform:scale() with a transition or animation.
However, only in Firefox, the text is blurry until the transition (or animation) is complete. Oddly, the border of the circle remains perfectly sharp (I think?).
Thinking maybe it needed a moment to pre-render, I've tried delaying with setTimeout alone, as well as combining with events (open & DOMContentLoaded) and with requestAnimationFrame. I also tried using css animation instead of transition.
Nothing seems to make a difference in Firefox, yet Chrome and Edge seem fine. Is there a prefix that I don't know about, or is this maybe a rendering bug in Firefox?
My MCSE is the snippet below:
setTimeout(function(){
circ.classList.remove('shrunk');
},500);
body{ font-family:'fira code'; font-size:20px; }
#circ{ position:relative; border:3px solid blue; border-radius:50%; text-align:center; white-space: nowrap; transition:transform 1000ms; }
#circ span{ position:absolute; left:50%; top:50%; transform:translate(-50%,-50%); }
.shrunk{ transform:scale(0.1); }
<div class='shrunk' id='circ' style='width:336px; height:336px;'>
<span>Lorem<br>Ipsum is simply<br>dummy text of the<br>printing and typesetting<br>industry. Lorem Ipsum has<br>been the industry's<br>standard dummy text ever<br>since the 1500s, when an<br>unknown printer took a<br>galley of type and<br>scrambled it to make<br>a type specimen<br>book.</span>
</div>
Any suggestions or workarounds?
I can only guess why this happens. Firefox is taking a snapshot before starting the animation / transition (by adding the class to the tag) and then when the transition ends. Maybe Firefox is taking more than two snapshots. But as you can see in the snippet below, the animation label is still blurred and waiting for when the animation is finished; the blur then disappears immediately. I think Firefox does this optimization for better performance.
The CSS property will-change also does not solve this problem if reset to initial .
setTimeout(function() {
circ.classList.add('shrunk');
}, 2000);
body {
display: flex;
flex-flow: column;
font-family: 'fira code';
gap: 2rem;
}
.circles,
.titles {
width: 100%;
display: flex;
gap: 2rem;
}
h4 {
width: 105px;
font-size: 0.8rem;
}
#circ,
#circ2,
#circ3,
#circ4 {
width: 100px;
height: 100px;
position: relative;
border: 3px solid blue;
border-radius: 50%;
text-align: center;
word-break: break-all;
}
#circ {
transition: transform 1000ms;
transform: scale(0.1);
}
#circ2 {
animation: forwardAnim 5s linear forwards;
}
#circ3 {
animation: forwardAnim 5s linear forwards;
backface-visibility: hidden;
}
#circ4 {
animation: forwardAnim 5s linear forwards;
transform-style: preserve-3d;
}
#circ span,
#circ2 span,
#circ3 span,
#circ4 span {
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
}
#circ.shrunk {
transform: scale(1);
}
#keyframes forwardAnim {
0% {
transform: scale(0.1);
}
45% {
transform: scale(0.1);
}
50% {
transform: scale(1);
}
100% {
transform: scale(1);
}
}
<div class="circles">
<div id="circ">
<span>This is my text!</span>
</div>
<div id="circ2">
<span>This is my text!</span>
</div>
<div id="circ3">
<span>This is my text!</span>
</div>
<div id="circ4">
<span>This is my text!</span>
</div>
</div>
<div class="titles">
<h4>Add class with transition</h4>
<h4>Animation</h4>
<h4>Animation with backface-visibility: hidden</h4>
<h4>Animation with transform-style: preserve-3d</h4>
</div>
To avoid this you could use backface-visibility: hidden;as #nullptr mentions above, or transform-style: preserve-3d;* for a smoother transition.
setTimeout(function() {
circ.classList.remove('shrunk');
}, 500);
setTimeout(function() {
circ2.classList.remove('shrunk');
}, 500);
body {
display: flex;
flex-flow: column;
font-family: 'fira code';
gap: 2rem;
font-size: 0.9rem;
}
.circles,
.titles {
width: 100%;
display: flex;
gap: 2rem;
}
h4 {
width: 255px;
font-size: 0.8rem;
text-align: center;
}
#circ,
#circ2 {
width: 250px;
height: 250px;
position: relative;
border: 3px solid blue;
border-radius: 50%;
text-align: center;
white-space: nowrap;
transition: transform 1000ms;
}
#circ {
backface-visibility: hidden;
}
#circ2 {
transform-style: preserve-3d;
}
#circ span,
#circ2 span {
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
}
.shrunk {
transform: scale(0.1);
}
<div class="circles">
<div class="shrunk" id="circ">
<span>Lorem<br />Ipsum is simply<br />dummy text of the<br />printing and
typesetting<br />industry. Lorem Ipsum has<br />been the industry's<br />standard
dummy text ever<br />since the 1500s, when an<br />unknown printer
took a<br />galley of type and<br />scrambled it to make<br />a type
specimen<br />book.</span
>
</div>
<div class="shrunk" id="circ2">
<span
>Lorem<br />Ipsum is simply<br />dummy text of the<br />printing and
typesetting<br />industry. Lorem Ipsum has<br />been the industry's<br />standard
dummy text ever<br />since the 1500s, when an<br />unknown printer
took a<br />galley of type and<br />scrambled it to make<br />a type
specimen<br />book.</span
>
</div>
</div>
<div class="titles">
<h4>backface-visibility: hidden;</h4>
<h4>transform-style: preserve-3d;</h4>
</div>
Another way to avoid blurred content inside the circle is to remove position: absolute if it's not critical, and instead align content with display: flex on the parent element.
setTimeout(function() {
circ.classList.remove('shrunk');
}, 500);
body {
font-family: 'fira code';
font-size: 20px;
}
#circ {
display: flex;
justify-content: center;
align-items: center;
position: relative;
border: 3px solid blue;
border-radius: 50%;
text-align: center;
white-space: nowrap;
transition: transform 1000ms;
}
.shrunk {
transform: scale(0.1);
}
<div class="shrunk" id="circ" style="width: 336px; height: 336px">
<span>Lorem<br />Ipsum is simply<br />dummy text of the<br />printing and
typesetting<br />industry. Lorem Ipsum has<br />been the industry's<br />standard
dummy text ever<br />since the 1500s, when an<br />unknown printer took
a<br />galley of type and<br />scrambled it to make<br />a type
specimen<br />book.</span
>
</div>
I ran into this issue a few years back, although I think I had it on chrome and not Firefox. But this seems to solve the issue in Firefox too.
Add backface-visibility: hidden to your transforming component. This will make it so that only the front face of the element is animated, instead of both the front and the back faces.
setTimeout(function(){
circ.classList.remove('shrunk');
},500);
body{ font-family:'fira code'; font-size:20px; }
#circ{ position:relative; border:3px solid blue; border-radius:50%; text-align:center; white-space: nowrap; transition:transform 1000ms; backface-visibility: hidden; }
#circ span{ position:absolute; left:50%; top:50%; transform:translate(-50%,-50%); }
.shrunk{ transform:scale(0.1); }
<div class='shrunk' id='circ' style='width:336px; height:336px;'>
<span>Lorem<br>Ipsum is simply<br>dummy text of the<br>printing and typesetting<br>industry. Lorem Ipsum has<br>been the industry's<br>standard dummy text ever<br>since the 1500s, when an<br>unknown printer took a<br>galley of type and<br>scrambled it to make<br>a type specimen<br>book.</span>
</div>
As to why it works, I really have no idea. But do try it and let me know it if works for you.
I'm trying to reveal text from the center against an element that has a background image. If I make the background of the animation a solid color, then that solid color appears around the text until the animation is done. If I put the same background image behind the text as is the behind the containing element, then a different version of that same image appears around my text. Any suggestions?
html:
<div class="container-big" id="the-wall">
<div class="chapter-hed">
<h5>PART 1</h5>
<h4 class="showhead">My heading</h4>
</div>
</div>
css:
#the-wall {
background-image: url(../img/wopo-3.png);
background-position: center;
background-size: cover;
background-color: black;
}
.chapter-hed h4 {
font-family: 'proxima-nova';
font-weight: 700;
font-size: 5rem;
letter-spacing: -2.4px;
line-height: 6.2rem;
text-align: center;
color: white;
margin: 0 auto;
border-bottom: 10px solid #e40d0d;
}
.chapter-hed h4:before {
left:0;
}
.chapter-hed h4:after {
right:0;
}
.chapter-hed h4:after,.chapter-hed h4:before {
position:absolute;
content:"";
height:100%;
height: 109px;
/*background:black;*/
background-image: url(../img/wopo-3.png);
background-position: center;
background-size: cover;
background-color: black;
}
.showhead:after, .showhead:before {
animation: revealText 4s;
animation-fill-mode:forwards;
}
#keyframes revealText {
0% {
width:50%
}
100% {
width:0%
}
}
I have added 2 wrappers for your class. One slides to the left, the other to the right. The net effect is that the element keeps centered, and is revealed progressively
#the-wall {
background-image: url(http://lorempixel.com/400/200);
background-position: center;
background-size: cover;
background-color: black;
}
.showheadctn1,
.showheadctn2 {
width: 100%;
overflow: hidden;
}
.showheadctn1 {
transform: translateX(50%);
}
.showheadctn2 {
transform: translateX(-100%);
}
.showhead {
font-family: 'proxima-nova';
font-weight: 700;
font-size: 5rem;
letter-spacing: -2.4px;
line-height: 6.2rem;
text-align: center;
color: white;
margin: 0 auto;
border-bottom: 10px solid #e40d0d;
width: 100%;
transform: translateX(50%);
}
.showheadctn1,
.showheadctn2,
.showhead {
animation: revealText 4s infinite;
animation-fill-mode: forwards;
}
#keyframes revealText {
0% {}
100% {
transform: translateX(0%);
}
}
<div class="container-big" id="the-wall">
<div class="chapter-hed">
<h5>PART 1</h5>
<div class="showheadctn1">
<div class="showheadctn2">
<h4 class="showhead">My heading</h4>
</div>
</div>
</div>
</div>
You can make 3 layers.
The bottom of the image you want.
In between the text.
The front again the image, but this time split in half.
And you do the same animation you have now but backwards. (On the third layer, logically)
Sure there is a more appropriate solution, but it is the first thing that has happened to me in my head
I'm working on a site with a knotted rope-style bar that expands to show more information on hover, and I'm having issues getting the animation to look right. (Here's a staging link: http://couchcreative.co/tcc/).
Currently, the bar for the first step will move down to the bottom of the box before it animates upwards to its new position, while I want it to just move up to its new position on hover without starting at the bottom of the hover box. Can anyone help explain why this is happening? The relevant CSS starts with the ".look" class.
Apologies if I'm not explaining this right, but hopefully when you visit the site you'll see what I mean about the animation looking a bit… off. Thanks for the help!
I would rework your HTML structure to make it more semantic and less repetitious.
Demo: http://jsfiddle.net/krmn4/5/
HTML:
<a href="/testicularcancer/" class="look">
<figure><img src="http://couchcreative.co/tcc/img/look.png" /></figure>
<div class="bar"></div>
<div class="off">
<h4>Look</h4>
</div>
<div class="on">
<h4>Relax your scrotum.</h4>
<p>Check your testicles just after you’ve had a bath or shower, when the muscles in the scrotum are relaxed, making it easier for you to feel any lumps, growths or tenderness. Stand in front of the mirror. Look for any swelling on the skin of your scrotum.</p>
<span>Learn More</span>
</div>
</a>
CSS:
.look {
position: absolute;
bottom: 0;
left: 0;
width: 235px;
overflow: hidden;
/* optional styling */
color: #000;
text-align: center;
text-decoration: none;
}
.look h4 {
/* optional styling */
line-height: 48px;
font-size: 20px;
font-weight: bold;
}
.look .bar {
height: 48px;
background: url(http://couchcreative.co/tcc/img/step_1.png) 0 0 repeat-x;
margin: -24px 0 0; /* half of height */
/* necessary so figure img doesn't overlap */
position: relative;
z-index: 1;
}
.look figure,
.look .off,
.look .on {
-webkit-transition: all 300ms linear;
-moz-transition: all 300ms linear;
transition: all 300ms linear;
height: 0;
opacity: 0;
overflow: hidden;
}
.look figure {
/* optional styling */
background-color: #b2d5e6;
padding: 12px;
margin: 0;
}
.look .off {
height: 48px;
opacity: 1;
}
/* hover state */
.look:hover .off {
height: 0;
opacity: 0;
}
.look:hover figure {
height: 120px; /* or however tall it needs to be */
opacity: 1;
}
.look:hover .on {
height: 220px; /* or however tall it needs to be */
opacity: 1;
}