I am trying to have a hover work after a css animation.
The animation changes size and colour of a circle using keyframes, however after the animation is complete, the colour it finishes on will not change on hover as it normally would.
body {
background: black;
}
#panorama {
position: fixed;
margin: auto;
top: 0;
right: 0;
bottom: 4vw;
left: 0;
-webkit-border-radius: 50%;
-moz-border-radius: 50%;
border-radius: 50%;
}
#panorama.large {
width: 17vw;
height: 17vw;
}
#panorama.black {
background-color: black;
border: solid rgba(255, 255, 255, 0.4) 1px;
-webkit-filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.6));
-moz-filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.6));
filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.6));
}
#panorama.glow {
animation-duration: 1s;
animation-timing-function: ease-out;
animation-delay: 0.7s;
animation-fill-mode: forwards;
}
#panorama.large.black.glow {
animation-name: panoramaLargeBlackGlowDownTurnOn;
}
#keyframes panoramaLargeBlackGlowDownTurnOn {
0% {
width: 17vw;
height: 17vw;
background-color: black;
}
99% {
background-color: black;
}
100% {
width: 3.5vw;
height: 3.5vw;
background-color: white;
-webkit-filter: drop-shadow(0 0 6px rgba(255, 255, 255, 1));
-moz-filter: drop-shadow(0 0 6px rgba(255, 255, 255, 1));
filter: drop-shadow(0 0 6px rgba(255, 255, 255, 1));
}
}
#panorama.large.black.glow:hover {
background-color: red !important;
}
<a href="#">
<div id="panorama" class="large black glow"></div>
</a>
or see the code here: JSFiddle
This is because you are using forwards which will force the use of the last state of your animation and you cannot override it. To overcome this you can consider CSS variable to define the background coloration and you simply change the variable to change the background
body {
background: black;
}
#panorama {
position: fixed;
margin: auto;
top: 0;
right: 0;
bottom: 4vw;
left: 0;
border-radius: 50%;
}
#panorama.large {
width: 17vw;
height: 17vw;
}
#panorama.black {
background-color: black;
border: solid rgba(255, 255, 255, 0.4) 1px;
filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.6));
}
#panorama.glow {
animation-duration: 1s;
animation-timing-function: ease-out;
animation-delay: 0.7s;
animation-fill-mode: forwards;
}
#panorama.large.black.glow {
animation-name: panoramaLargeBlackGlowDownTurnOn;
}
#keyframes panoramaLargeBlackGlowDownTurnOn {
0% {
width: 17vw;
height: 17vw;
background-color: black;
}
99% {
background-color: black;
}
100% {
width: 3.5vw;
height: 3.5vw;
background-color: var(--c,#fff);
filter: drop-shadow(0 0 6px rgba(255, 255, 255, 1));
}
}
#panorama.large.black.glow:hover {
--c: red;
}
<a href="#">
<div id="panorama" class="large black glow"></div>
</a>
Another idea is to use an inset box-shadow for the coloration:
body {
background: black;
}
#panorama {
position: fixed;
margin: auto;
top: 0;
right: 0;
bottom: 4vw;
left: 0;
border-radius: 50%;
}
#panorama.large {
width: 17vw;
height: 17vw;
}
#panorama.black {
background-color: black;
border: solid rgba(255, 255, 255, 0.4) 1px;
filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.6));
}
#panorama.glow {
animation-duration: 1s;
animation-timing-function: ease-out;
animation-delay: 0.7s;
animation-fill-mode: forwards;
}
#panorama.large.black.glow {
animation-name: panoramaLargeBlackGlowDownTurnOn;
}
#keyframes panoramaLargeBlackGlowDownTurnOn {
99% {
background-color: black;
}
100% {
width: 3.5vw;
height: 3.5vw;
background-color: #fff;
filter: drop-shadow(0 0 6px rgba(255, 255, 255, 1));
}
}
#panorama.large.black.glow:hover {
box-shadow:0 0 0 50vw red inset;
border-color:rgba(255, 0, 0, 0.6); /*we also change the border since background is also visible under the border*/
}
<a href="#">
<div id="panorama" class="large black glow"></div>
</a>
Related
I have an h1 element that I want to be invisible and then appear after a few seconds. The element has an ::after pseudo-element that displays a data-text attribute that shadows the h1 element. When I add the animation, I only see the h1 and not the pseudo-element as well. Here is my code
EDIT
adding the animation to the pseudo-element makes it appear, but now the data-text appears over the h1 element when originally it is supposed to go behind it. Here are some pic of what is happening. The first is what it is doing and the second is what I want.
EDIT 2
The problem can be recreated by removing the z-index on the pseudo-element.
<section class="wrapper">
<div class="content-wrapper">
<img class="flipInY" src="./img/neon-blue - flip.png" alt="logo-triangle">
<h1 class="name-ani" data-text="My Name">My Name</h1>
<h2 data-text="web-dev">Web Developer</h2>
</div>
</section>
.wrapper {
.content-wrapper {
z-index: 0;
position: relative;
display: grid;
justify-items: center;
margin-top: 20vh;
img {
width: 350px;
max-width: 100%;
padding: 0 32px;
// transform: rotate(180deg);
filter: brightness(85%);
position: relative;
}
h1 {
background: linear-gradient(
to bottom,
#ebf1f6 0%,
#abd3ee 50%,
#859ee2 51%,
#d5ebfb 100%
);
-webkit-background-clip: text;
background-clip: text;
-webkit-text-fill-color: transparent;
font-family: kimberly;
text-transform: uppercase;
font-size: 2.25rem;
transition: font-size 1s;
position: absolute;
top: 10%;
opacity: 0;
&::after {
background: none;
content: attr(data-text);
left: 0;
position: absolute;
text-shadow: 1px -1px 0 rgba(255, 255, 255, 0.5),
3px 1px 3px rgba(255, 0, 255, 0.85),
-3px -2px 3px rgba(0, 0, 255, 0.85),
1px -2px 0 rgba(255, 255, 255, 0.8);
z-index: -10;
opacity: 0;
}
}
.name-ani {
animation-name: name-ani;
animation-duration: 250ms;
animation-delay: 4.5s;
animation-fill-mode: forwards;
}
#keyframes name-ani {
0% {
opacity: 0;
}
100% {
opacity: 1;
}
}
You need to apply the animation to the pseudo-element as well.
.name-ani,
.name-ani::after {
animation-name: name-ani;
animation-duration: 250ms;
animation-delay: 4.5s;
animation-fill-mode: forwards;
}
Edit: Getting rid of the position: absolute on the h1 by wrapping it and giving it an display: inline solved the stacking order for me as well.
<section class="wrapper">
<div class="content-wrapper">
<img class="flipInY" src="./img/neon-blue - flip.png" alt="logo-triangle">
<div class="h1-wrapper">
<h1 class="name-ani" data-text="My Name">My Name</h1>
</div>
<h2 data-text="web-dev">Web Developer</h2>
</div>
</section>
.wrapper {
.content-wrapper {
z-index: 0;
position: relative;
display: grid;
justify-items: center;
margin-top: 20vh;
img {
width: 350px;
max-width: 100%;
padding: 0 32px;
filter: brightness(85%);
position: relative;
}
.h1-wrapper {
position: absolute;
top: 10%;
}
h1 {
background: linear-gradient(to bottom,
#ebf1f6 0%,
#abd3ee 50%,
#859ee2 51%,
#d5ebfb 100%);
-webkit-background-clip: text;
background-clip: text;
-webkit-text-fill-color: transparent;
font-family: kimberly;
text-transform: uppercase;
font-size: 2.25rem;
transition: font-size 1s;
display: inline;
opacity: 0;
&::after {
background: none;
content: attr(data-text);
left: 0;
position: absolute;
text-shadow: 1px -1px 0 rgba(255, 255, 255, 0.5),
3px 1px 3px rgba(255, 0, 255, 0.85),
-3px -2px 3px rgba(0, 0, 255, 0.85),
1px -2px 0 rgba(255, 255, 255, 0.8);
z-index: -10;
opacity: 0;
}
}
.name-ani,
.name-ani::after {
animation-name: name-ani;
animation-duration: 250ms;
animation-delay: 4.5s;
animation-fill-mode: forwards;
}
#keyframes name-ani {
0% {
opacity: 0;
}
100% {
opacity: 1;
}
}
}
}
I want my button to fill with the gradient color on hover with a transect ion effect from left to right, initially the button is with white background
old answer has the reverse effect what i am looking for is not the same
My html code
Read more
I want to know how to achieve it by using CSS.
Check this one:
*{
padding:5px;
}
a{
text-decoration:none !important;
}
a:hover{
text-decoration:none !important;
}
.button {
display: block;
position: relative;
padding: 10px 0;
width: 150px;
border-radius:5px;
color: #fff;
text-align: center;
background-color: #774df4;
border: none;
}
.button.one:after {
content: '';
position: absolute;
top: 0;
left: 0;
width: 0;
height: 100%;
background-color: rgba(255,255,255,0.4);
-webkit-transition: none;
-moz-transition: none;
transition: none;
}
.button.one:hover:after {
width: 120%;
background-color: rgba(255,255,255,0);
-webkit-transition: all 0.4s ease-in-out;
-moz-transition: all 0.4s ease-in-out;
transition: all 0.4s ease-in-out;
}
/* Two */
.button.two {
background-repeat: no-repeat;
background-position: -120px -120px, 0 0;
background-image: -webkit-linear-gradient(
top left,
rgba(255, 255, 255, 0.2) 0%,
rgba(255, 255, 255, 0.2) 37%,
rgba(255, 255, 255, 0.8) 45%,
rgba(255, 255, 255, 0.0) 50%
);
background-image: -moz-linear-gradient(
0 0,
rgba(255, 255, 255, 0.2) 0%,
rgba(255, 255, 255, 0.2) 37%,
rgba(255, 255, 255, 0.8) 45%,
rgba(255, 255, 255, 0.0) 50%
);
background-image: -o-linear-gradient(
0 0,
rgba(255, 255, 255, 0.2) 0%,
rgba(255, 255, 255, 0.2) 37%,
rgba(255, 255, 255, 0.8) 45%,
rgba(255, 255, 255, 0.0) 50%
);
background-image: linear-gradient(
0 0,
rgba(255, 255, 255, 0.2) 0%,
rgba(255, 255, 255, 0.2) 37%,
rgba(255, 255, 255, 0.8) 45%,
rgba(255, 255, 255, 0.0) 50%
);
-moz-background-size: 250% 250%, 100% 100%;
background-size: 250% 250%, 100% 100%;
-webkit-transition: background-position 0s ease;
-moz-transition: background-position 0s ease;
-o-transition: background-position 0s ease;
transition: background-position 0s ease;
}
.button.two:hover {
background-position: 0 0, 0 0;
-webkit-transition-duration: 0.5s;
-moz-transition-duration: 0.5s;
transition-duration: 0.5s;
}
/* Last Button css starts */
.c-button {
color: #000;
font-weight: 700;
font-size: 1em;
text-decoration: none;
padding: 0.7em 1.8em;
cursor: pointer;
display: inline-block;
}
.c-button--gooey {
color: #06c8d9;
font-size: 1.3em;
letter-spacing: 2px;
border-radius:5px;
border: 2px solid #06c8d9;
padding: 1.2em 3.4em;
position: relative;
transition: all 700ms ease;
}
.c-button--gooey .c-button__blobs {
filter: url(#goo);
overflow: hidden;
position: absolute;
top: 0;
left: 0;
bottom: -3px;
right: -1px;
z-index: -1;
}
.c-button--gooey .c-button__blobs div {
background:linear-gradient(to right,#61dce4,#0083ef);
width: 100%;
height: 100%;
border-radius: 100%;
position: absolute;
transform: scale(2) translateX(-250%) translateZ(0);
transition: all 1.1s ease;
}
.c-button--gooey:hover {
color: #fff;
}
.c-button--gooey:hover .c-button__blobs div {
transform: scale(2.4) translateX(15%) translateZ(0);
}
<br/>
Button 1
<br />
BUTTON 2
<br />
<input name="" value="Submit" type="submit" class="button two">
<br/>
<a href=" " class="c-button c-button--gooey">
BUTTON <div class="c-button__blobs">
<div></div>
</div>
</a>
I need to change the animation with a transition effect. That is change first transition to another with a flow. When I tried for the same the animation changes with a fast change as in below snippet. Is there any way to animate the change in animation. I have tried the below code.
body{
background: url('https://i.pinimg.com/originals/0b/76/08/0b760848c89b9e4abd03f74f19419498.jpg');
}
.bubble{
top: 50px;
left: 80px;
height: 100px;
width: 100px;
color: #000;
box-sizing: border-box;
border-radius: 50%;
box-shadow: 0 5px 15px 0px rgba(0,0,0,0.4);
transform: translatey(0px);
cursor: pointer;
position: absolute;
border: 10px solid rgba(255,255,255,0.2);
animation: float 4s ease-in-out infinite;
}
.bubble span {
font-size: 12px;
line-height: 85px;
position: absolute;
bottom: 0;
top: 0;
right: 0;
left: 0;
text-align: center;
border-radius: 50%;
background: red;
}
.bubble:before {
position: absolute;
content: "";
top: 0px;
bottom: 0px;
left: 0px;
right: 0px;
border-radius: 50%;
box-shadow: 0 0 rgba(255, 255, 255, 0.1), 0 0 0 8px rgba(255, 255, 255, 0.1),
0 0 0 16px rgba(255, 255, 255, 0.1), 0 0 0 24px rgba(255, 255, 255, 0.1);
z-index: -1;
animation: ripples 1s linear infinite;
animation-play-state: paused;
opacity: 0;
visibility: hidden;
transition: 0.5s;
transform: scale(0.5);
}
.bubble:hover {
transition: all 2s;
animation: tofixed 4s forwards;
box-shadow: none;
border-color: transparent;
}
.bubble:hover:before {
animation-play-state: running;
opacity: 1;
visibility: visible;
transform: scale(1);
}
#keyframes float {
0% { box-shadow: 0 5px 15px 0px rgba(0,0,0,0.6); transform: translatey(0px) scale(0.9); }
50% { box-shadow: 0 25px 15px 0px rgba(0,0,0,0.2); transform: translatey(-20px) scale(1); }
100% { box-shadow: 0 5px 15px 0px rgba(0,0,0,0.6); transform: translatey(0px) scale(0.9); }
}
#keyframes tofixed {
to { transform: translatey(0px) scale(0.9); }
}
#keyframes ripples {
to {
box-shadow: 0 0 0 8px rgba(255, 255, 255, 0.1), 0 0 0 16px rgba(255, 255, 255, 0.1),
0 0 0 24px rgba(255, 255, 255, 0.1), 0 0 0 32px rgba(255, 255, 255, 0);
}
}
<div class="bubble">
<span class="bgviolet">ODOSTORE</span>
</div>
In the above snippet you can see the change in animation is instantly when I hover on it.
I have the following JS fiddle: https://jsfiddle.net/ur9bpgbn/163/
.arrow {
position: absolute;
font-size: 16px;
max-width: 350px;
background: #FFF;
height: 40px;
line-height: 40px;
margin-bottom: 20px;
text-align: center;
color: #000;
box-shadow: 3px 5px 5px rgba(0, 0, 0, 0.2);
visibility: hidden;
opacity: 0;
transition: visibility 0s, opacity 0.3s ease-in-out;
z-index: 999;
}
.arrow.active {
visibility: visible;
opacity: 1;
}
.arrow.active.animate-left-to-right {
animation-name: move-left-to-right;
animation-duration: 1s;
animation-delay: 0.6s;
animation-iteration-count: infinite;
animation-direction: alternative;
}
.arrow.active.animate-right-to-left {
animation-name: move-right-to-left;
animation-duration: 1s;
animation-delay: 0.6s;
animation-iteration-count: infinite;
animation-direction: alternative;
}
#keyframes move-left-to-right {
0% {
transform: translateX (5%);
box-shadow: 3px 5px 5px rgba(0, 0, 0, 0.2);
}
50% {
transform: translateX(15%);
box-shadow: 3px 5px 5px rgba(0, 0, 0, 0.4);
}
100% {
transform: translateX(5%);
box-shadow: 3px 5px 5px rgba(0, 0, 0, 0.2);
}
}
#keyframes move-right-to-left {
0% {
transform: translateX(-5%);
box-shadow: -3px 5px 5px rgba(0, 0, 0, 0.2);
}
50% {
transform: translateX(-15%);
box-shadow: -3px 5px 5px rgba(0, 0, 0, 0.4);
}
100% {
transform: translateX(-5%);
box-shadow: -3px 5px 5px rgba(0, 0, 0, 0.2);
}
}
/*right arrow*/
.arrow-right {
border-radius: 0px 0px 0 0px;
background: linear-gradient(to right, rgba(255, 255, 255, 1), rgba(255, 255, 255, 0.7));
}
.arrow-right:after {
content: "";
position: absolute;
right: -20px;
top: 0;
border-top: 20px solid transparent;
border-bottom: 20px solid transparent;
border-left: 20px solid #FFF;
opacity: 0.7;
}
.arrow-right:before {
content: "";
position: absolute;
left: -20px;
top: 0;
border-top: 0px solid transparent;
border-bottom: 40px solid transparent;
border-right: 20px solid #FFF;
opacity: 1;
}
/*left arrow*/
.arrow-left {
border-radius: 0 0px 0px 0;
background: linear-gradient(to left, rgba(255, 255, 255, 1), rgba(255, 255, 255, 0.7));
}
.arrow-left:before {
content: "";
position: absolute;
left: -20px;
top: 0;
border-top: 20px solid transparent;
border-bottom: 20px solid transparent;
border-right: 20px solid #FFF;
opacity: 0.7;
}
.arrow-left:after {
content: "";
position: absolute;
right: -20px;
top: 0;
border-top: 0px solid transparent;
border-bottom: 40px solid transparent;
border-left: 20px solid #FFF;
opacity: 1;
}
<div id="app">
<a href="https://sporedev.ro" target="_blank">
<div href="#" class="arrow arrow-right animate-right-to-left">This is a text</div>
</a>
<div href="#" class="arrow arrow-left animate-left-to-right" style="margin-top:30%; margin-left:30%;"><span class="room-desc">This is a text</span></div>
</div>
The arrow that moves to the right side works perfectly.
The arrow to the left side has some kind of a glitch, it has a sudden move when it reaches the end of the transition.
I tried applying changes to the CSS in everything related to the left arrow with no effect. The script has some JS that adds the "active" class and I tried removing it to simplify the script and make sure it's not a JS related problem with no effect.
Tried reading up transitions but I didn't found any solutions. I'm sure that I miss something that is CSS related.
How can I make the arrow that points to the left side move smoothly?
Update this part transform: translateX (5%); to transform: translateX (0%);
#keyframes move-left-to-right {
0% {
transform: translateX (0%);
box-shadow: 3px 5px 5px rgba(0, 0, 0, 0.2);
}
50% {
transform: translateX(15%);
box-shadow: 3px 5px 5px rgba(0, 0, 0, 0.4);
}
100% {
transform: translateX(0%);
box-shadow: 3px 5px 5px rgba(0, 0, 0, 0.2);
}
}
https://jsfiddle.net/ur9bpgbn/168/
I believe the little jump is the 0-5% which it is not animating so it just jumps
I was just looking at a simple SVG cake animation HERE , the CSS code looks like so:
#import url(http://fonts.googleapis.com/css?family=Lato:300italic);
html,
body {
width: 100%;
height: 100%;
}
body {
background: #ee9ca7;
}
#cake {
display: block;
position: relative;
margin: -10em auto 0 auto;
}
*/* ============================================== Candle
*/
.velas {
background: #ffffff;
border-radius: 10px;
position: absolute;
top: 228px;
left: 50%;
margin-left: -2.4px;
margin-top: -8.33333333px;
width: 5px;
height: 35px;
transform: translateY(-300px);
backface-visibility: hidden;
animation: in 500ms 6s ease-out forwards;
}
.velas:after,
.velas:before {
background: rgba(255, 0, 0, 0.4);
content: "";
position: absolute;
width: 100%;
height: 2.22222222px;
}
.velas:after {
top: 25%;
left: 0;
}
.velas:before {
top: 45%;
left: 0;
}
/* ============================================== Fire
*/
.fuego {
border-radius: 100%;
position: absolute;
top: -20px;
left: 50%;
margin-left: -2.6px;
width: 6.66666667px;
height: 18px;
}
.fuego:nth-child(1) {
animation: fuego 2s 6.5s infinite;
}
.fuego:nth-child(2) {
animation: fuego 1.5s 6.5s infinite;
}
.fuego:nth-child(3) {
animation: fuego 1s 6.5s infinite;
}
.fuego:nth-child(4) {
animation: fuego 0.5s 6.5s infinite;
}
.fuego:nth-child(5) {
animation: fuego 0.2s 6.5s infinite;
}
/* ============================================== Animation Fire
*/
#keyframes fuego {
0%, 100% {
background: rgba(254, 248, 97, 0.5);
box-shadow: 0 0 40px 10px rgba(248, 233, 209, 0.2);
transform: translateY(0) scale(1);
}
50% {
background: rgba(255, 50, 0, 0.1);
box-shadow: 0 0 40px 20px rgba(248, 233, 209, 0.2);
transform: translateY(-20px) scale(0);
}
}
#keyframes in {
to {
transform: translateY(0);
}
}
.text {
color: #8b6a60;
font-family: 'Lato', sans-serif;
font-weight: 300;
font-style:italic;
text-align: center;
h1 {
font-size: 1.4em;
}
}
After inspecting the code a bit i came to know the candle flame was caused by this set of HTML elements:
<div class="velas">
<div class="fuego"></div>
<div class="fuego"></div>
<div class="fuego"></div>
<div class="fuego"></div>
<div class="fuego"></div>
</div>
And this HTML has the following CSS code:
background: #ffffff;
border-radius: 10px;
position: absolute;
top: 228px;
left: 50%;
margin-left: -2.4px;
margin-top: -8.33333333px;
width: 5px;
height: 35px;
transform: translateY(-300px);
backface-visibility: hidden;
animation: in 500ms 6s ease-out forwards;
}
.velas:after,
.velas:before {
background: rgba(255, 0, 0, 0.4);
content: "";
position: absolute;
width: 100%;
height: 2.22222222px;
}
.velas:after {
top: 25%;
left: 0;
}
.velas:before {
top: 45%;
left: 0;
}
/* ============================================== Fire
*/
.fuego {
border-radius: 100%;
position: absolute;
top: -20px;
left: 50%;
margin-left: -2.6px;
width: 6.66666667px;
height: 18px;
}
.fuego:nth-child(1) {
animation: fuego 2s 6.5s infinite;
}
.fuego:nth-child(2) {
animation: fuego 1.5s 6.5s infinite;
}
.fuego:nth-child(3) {
animation: fuego 1s 6.5s infinite;
}
.fuego:nth-child(4) {
animation: fuego 0.5s 6.5s infinite;
}
.fuego:nth-child(5) {
animation: fuego 0.2s 6.5s infinite;
}
/* ============================================== Animation Fire
*/
#keyframes fuego {
0%, 100% {
background: rgba(254, 248, 97, 0.5);
box-shadow: 0 0 40px 10px rgba(248, 233, 209, 0.2);
transform: translateY(0) scale(1);
}
50% {
background: rgba(255, 50, 0, 0.1);
box-shadow: 0 0 40px 20px rgba(248, 233, 209, 0.2);
transform: translateY(-20px) scale(0);
}
}
#keyframes in {
to {
transform: translateY(0);
}
}
Now i don't see the CSS code that is actually cauing the red and yellow flame , i beleive the white shadow is caused by the very high box shadow given in the animations , but somehow i don't see where the candle flame is created , can somebody guide me as to where the candle flame is really created ?
The colors are set by RGB values. There's a yellow, red, and some pink.
#keyframes fuego {
0%, 100% {
background: rgba(254, 248, 97, 0.5); /* yellow */
box-shadow: 0 0 40px 10px rgba(248, 233, 209, 0.2); /* pink */
transform: translateY(0) scale(1);
}
50% {
background: rgba(255, 50, 0, 0.1); /* red */
box-shadow: 0 0 40px 20px rgba(248, 233, 209, 0.2); /* pink again */
transform: translateY(-20px) scale(0);
}
}
Timings to change the colors are set in .fuego:nth-child(1) through .fuego:nth-child(6)