Reset CSS animation when not hovering - html

I would like to reset my animation when hover out from div. This code is from Codepen.io and edited for my purpose.I want border animation to reset when i hover out form div. now it stays fully animated. I'm beginner with coding i am learning by trial and error.
#keyframes bg {
0% { background-size: 0 5px, 5px 0, 0 5px, 5px 0; }
25% { background-size: 100% 5px, 5px 0, 0 5px, 5px 0; }
50% { background-size: 100% 5px, 5px 100%, 0 5px, 5px 0; }
75% { background-size: 100% 5px, 5px 100%, 100% 5px, 5px 0; }
100% { background-size: 100% 5px, 5px 100%, 100% 5px, 5px 100%; }
}
.box {
width: 100%;
margin: 2rem auto;
padding: 2em;
color: white;
background-repeat: no-repeat;
background-image: linear-gradient(to right, #3d3d3d 100%, #3d3d3d 100%),
linear-gradient(to bottom, #3d3d3d 100%, #3d3d3d 100%),
linear-gradient(to right, #3d3d3d 100%, #3d3d3d 100%),
linear-gradient(to bottom, #3d3d3d 100%, #3d3d3d 100%);
background-size: 100% 5px, 5px 100%, 100% 5px, 5px 100%;
background-position: 0 0, 100% 0, 100% 100%, 0 100%;
animation: bg 1.25s cubic-bezier(0.19, 1, 0.22, 1) 1;
animation-play-state: paused;
animation-iteration-count: 1;
animation-timing-function: ease-in-out;
}
.box:hover h1{
animation-play-state: running;
animation-duration: 1s;
animation-iteration-count: 1;
animation-timing-function: ease-in-out;
color: #a1a1a1;
}
.box:hover p{
animation-play-state: running;
animation-duration: 1s;
animation-iteration-count: 1;
animation-timing-function: ease-in-out;
color: #a1a1a1;
}
.box h1 {
font-family: Raleway;
color: white;
font-weight: bold;
}
.box p {
font-family: inter;
}
<a href="http://local.local">
<div class="box">
<h1>Zdravotnictví</h1>
<p>Díky newsletteru Zdravotnictví vám neunikne žádná zpráva z oboru Zdravotního průmyslu, kterým tečou stovky miliard. Vychází každé úterý.</p>
</div>
</a>

Related

CSS move up / wipe up vertically animation? On scroll?

I'm working in React js and am trying to emulate the vertical move up animation you see on the text "A DIGITAL DESIGN STUDIO
DRIVEN BY RESEARCH &
STRATEGY" here - https://dashdigital.studio/
From inspecting this site I have tried working with their translation CSS -
transition-delay: .9s;
transition: transform 1.3s cubic-bezier(.075, .82, .165, 1);
transform: translateY(0%);
However there is the "moving up from behind a wall" effect in use that I can't find a starting point for. Ideally I'd have this occur to elements on scroll - is there a package or starting point for anything like this?
How can I create this vertical wipe from behind a wall effect?
You can create vertically animation by following this code
html, body {
height: 100%;
}
body {
font-family: "Baloo Paaji", cursive;
background: #1e90ff;
display: flex;
justify-content: center;
align-items: center;
}
.container {
width: 400px;
height: 220px;
position: relative;
}
h1, h2 {
font-size: 75px;
text-transform: uppercase;
}
h1 span, h2 span {
width: 100%;
float: left;
color: #ffffff;
-webkit-clip-path: polygon(100% 0, 100% 100%, 0 100%, 0 80%);
clip-path: polygon(100% 0, 100% 100%, 0 100%, 0 80%);
transform: translateY(-150px);
opacity: 0;
-webkit-animation-name: titleAnimation;
animation-name: titleAnimation;
-webkit-animation-timing-function: ease;
animation-timing-function: ease;
-webkit-animation-duration: 3s;
animation-duration: 3s;
}
h1 span {
-webkit-animation-delay: 0.6s;
animation-delay: 0.6s;
-webkit-animation-fill-mode: forwards;
}
h1 span:first-child {
-webkit-animation-delay: 0.7s;
animation-delay: 0.7s;
}
h1 span:last-child {
color: #ffe221;
-webkit-animation-delay: 0.5s;
animation-delay: 0.5s;
}
h2 {
top: 0;
position: absolute;
}
h2 span {
-webkit-animation-delay: 4.1s;
animation-delay: 4.1s;
-webkit-animation-fill-mode: forwards;
}
h2 span:first-child {
-webkit-animation-delay: 4.2s;
animation-delay: 4.2s;
}
h2 span:last-child {
color: #ffe221;
-webkit-animation-delay: 4s;
animation-delay: 4s;
}
.usechrome {
font-size: 10px;
color: #fff;
font-family: helvetica, arial;
position: absolute;
bottom: 20px;
width: 100%;
text-align: center;
left: 0;
}
#-webkit-keyframes titleAnimation {
0% {
transform: translateY(-50px);
opacity: 0;
-webkit-clip-path: polygon(100% 0, 100% 100%, 0 100%, 0 80%);
clip-path: polygon(100% 0, 100% 100%, 0 100%, 0 80%);
}
20% {
transform: translateY(0);
opacity: 1;
-webkit-clip-path: polygon(100% 0, 100% 100%, 0 100%, 0 15%);
clip-path: polygon(100% 0, 100% 100%, 0 100%, 0 15%);
}
80% {
transform: translateY(0);
opacity: 1;
-webkit-clip-path: polygon(100% 0, 100% 100%, 0 100%, 0 15%);
clip-path: polygon(100% 0, 100% 100%, 0 100%, 0 15%);
}
100% {
transform: translateY(50px);
opacity: 0;
-webkit-clip-path: polygon(100% 0, 100% 0%, 0 100%, 0 100%);
clip-path: polygon(100% 0, 100% 0%, 0 100%, 0 100%);
}
}
#keyframes titleAnimation {
0% {
transform: translateY(-50px);
opacity: 0;
-webkit-clip-path: polygon(100% 0, 100% 100%, 0 100%, 0 80%);
clip-path: polygon(100% 0, 100% 100%, 0 100%, 0 80%);
}
20% {
transform: translateY(0);
opacity: 1;
-webkit-clip-path: polygon(100% 0, 100% 100%, 0 100%, 0 15%);
clip-path: polygon(100% 0, 100% 100%, 0 100%, 0 15%);
}
80% {
transform: translateY(0);
opacity: 1;
-webkit-clip-path: polygon(100% 0, 100% 100%, 0 100%, 0 15%);
clip-path: polygon(100% 0, 100% 100%, 0 100%, 0 15%);
}
100% {
transform: translateY(50px);
opacity: 0;
-webkit-clip-path: polygon(100% 0, 100% 0%, 0 100%, 0 100%);
clip-path: polygon(100% 0, 100% 0%, 0 100%, 0 100%);
}
}/*# sourceMappingURL=style.css.map */
<section class="container">
<h1 class="title">
<span>Hi, nice</span>
<span>to see</span>
<span>you here</span>
</h1>
<h2 class="title">
<span>This is</span>
<span>a long</span>
<span>sub title</span>
</h2>
</section>
<span class="usechrome">Use Chrome for a better experience</span>

rotate animation render only half of the element

I'm trying to animate a rotating gold ray of lights, below image is the achieved layout using html and css but when I tried to add a rotate animation, seems layout cut on half. Below code snippet is what is my attempt. Any help, ideas is greatly appreciated.
#import('https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.3.1/css/bootstrap.min.css');
body {
background: #ededed;
padding: 64px 0;
font-family: Roboto, sans-serif;
font-size: 12px
}
.banner {
max-width: 100%;
max-height: 100%;
-webkit-box-shadow: 0 10px 40px -6px rgba(0, 0, 0, .1);
-moz-box-shadow: 0 10px 40px -6px rgba(0, 0, 0, .1);
-o-box-shadow: 0 10px 40px -6px rgba(0, 0, 0, .1);
box-shadow: 0 10px 40px -6px rgba(0, 0, 0, .1)
}
.winners-intro {
background: #ededed;
z-index: 999
}
.winners-intro,
.winners-intro .winners-light {
display: flex;
align-items: center;
justify-content: center;
width: 100%;
height: 100vh;
position: fixed;
top: 0;
left: 0
}
.winners-intro .winners-light {
-webkit-animation-name: winners_light;
-webkit-animation-duration: 10s;
-webkit-animation-iteration-count: infinite;
animation-name: winners_light;
animation-duration: 10s;
animation-iteration-count: infinite
}
.winners-intro .winners-light .radial-light {
width: 100px;
height: 100px;
background: gold;
box-shadow: 1px 1px 100px 50px gold;
-webkit-box-shadow: 1px 1px 100px 50px gold;
-moz-box-shadow: 1px 1px 100px 50px gold;
-o-box-shadow: 1px 1px 100px 50px gold;
-webkit-border-radius: 50%;
-moz-border-radius: 50%;
border-radius: 50%;
position: absolute
}
.winners-intro .winners-light .light {
position: absolute;
background: gold;
height: 200vh;
width: 20px;
opacity: .5;
background: transparent;
background: -webkit-linear-gradient(bottom, transparent 27%, gold 50%, transparent 73%, transparent 90%, transparent);
background: linear-gradient(0deg, transparent 27%, gold 50%, transparent 73%, transparent 90%, transparent)
}
.winners-intro .winners-light .light:nth-child(2) {
transform: skewX(30deg)
}
.winners-intro .winners-light .light:nth-child(2),
.winners-intro .winners-light .light:nth-child(3) {
background: transparent;
background: -webkit-linear-gradient(bottom, transparent 27%, gold 50%, transparent 73%, transparent 90%, transparent);
background: linear-gradient(0deg, transparent 27%, gold 50%, transparent 73%, transparent 90%, transparent)
}
.winners-intro .winners-light .light:nth-child(3) {
transform: skewX(60deg)
}
.winners-intro .winners-light .light:nth-child(4) {
transform: skewX(90deg)
}
.winners-intro .winners-light .light:nth-child(4),
.winners-intro .winners-light .light:nth-child(6) {
background: transparent;
background: -webkit-linear-gradient(bottom, transparent 27%, gold 50%, transparent 73%, transparent 90%, transparent);
background: linear-gradient(0deg, transparent 27%, gold 50%, transparent 73%, transparent 90%, transparent)
}
.winners-intro .winners-light .light:nth-child(6) {
transform: skewX(-30deg)
}
.winners-intro .winners-light .light:nth-child(7) {
transform: skewX(-60deg);
background: transparent;
background: -webkit-linear-gradient(bottom, transparent 27%, gold 50%, transparent 73%, transparent 90%, transparent);
background: linear-gradient(0deg, transparent 27%, gold 50%, transparent 73%, transparent 90%, transparent)
}
.winners-intro .winners-light .light:nth-child(8) {
width: 100%!important;
height: 10px!important;
background: transparent;
background: -webkit-linear-gradient(left, transparent 10%, gold 50%, transparent 90%, transparent);
background: linear-gradient(90deg, transparent 10%, gold 50%, transparent 90%, transparent)
}
.winners-intro .winners-trophy {
display: flex;
align-items: center;
justify-content: center;
width: 100%;
height: 100%;
position: absolute;
top: 0;
left: 0;
z-index: 10
}
#-webkit-keyframes winners_light {
to {
transform: rotate(-1turn)
}
}
#keyframes clouds {
to {
transform: rotate(-1turn)
}
}
<div class="winners-intro">
<div>
<div class="winners-light">
<div class="light"></div>
<div class="light"></div>
<div class="light"></div>
<div class="light"></div>
<div class="light"></div>
<div class="light"></div>
<div class="light"></div>
<div class="light"></div>
<div class="radial-light"></div>
</div>
</div>
</div>
I would simplify the code like below where you will not have the issue:
body {
background: #ededed;
margin:0;
overflow:hidden;
display:flex;
align-items:center;
justify-content:center;
height:100vh;
}
.light {
height: 100vmax;
width:100vmax;
background:
radial-gradient(circle ,rgba(255, 215, 0, 1 ) 8vmax,transparent 8vmax),
radial-gradient(circle ,rgba(255, 215, 0, 0.6)8vmax,transparent 17vmax),
linear-gradient(to bottom, transparent 10%,gold,transparent 90%) center/10px 100%,
linear-gradient(to right , transparent 10%,gold,transparent 90%) center/100% 10px;
background-repeat:no-repeat;
position:relative;
overflow:hidden;
animation:move 5s linear infinite;
}
.light:before,
.light:after{
content:"";
position:absolute;
top:0;
left:0;
right:0;
bottom:0;
background:inherit;
background-size:0 0,0 0,10px 100%,100% 10px;
transform:rotate(30deg);
}
.light:after{
transform:rotate(-30deg);
}
#keyframes move {
to {
transform:rotate(1turn);
}
}
<div class="light"></div>

Re-position radial gradient

I'm working on a ticket shape div, my problem is that I can't move the circles to the position I want.
I'm following this code:
* {
box-sizing: border-box;
}
body {
padding: 2em;
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
text-align: center;
background-color: #ff4500;
-webkit-animation: bg 10s linear infinite alternate;
animation: bg 10s linear infinite alternate;
color: rgba(0, 0, 0, 0.25);
font-size: 13px;
}
a {
color: rgba(0, 0, 0, 0.35);
}
.ticket {
display: inline-block;
box-sizing: content-box;
-webkit-filter: drop-shadow(0 2px 5px rgba(0, 0, 0, 0.5));
filter: drop-shadow(0 2px 5px rgba(0, 0, 0, 0.5));
position: relative;
height: 1em;
padding: 1em;
color: #000;
font-size: 16px;
background-size: 51% 100%;
background-repeat: no-repeat;
background-image: radial-gradient(circle at 0 50%, rgba(255, 255, 224, 0) 0.4em, #ffffe0 0.5em), radial-gradient(circle at 100% 50%, rgba(255, 255, 224, 0) 0.4em, #ffffe0 0.5em);
background-position: top left, top right;
}
#-webkit-keyframes bg {
0% {
background-color: #ff4500;
}
50% {
background-color: #b0e0e6;
}
100% {
background-color: #ff4500;
}
}
#keyframes bg {
0% {
background-color: #ff4500;
}
50% {
background-color: #b0e0e6;
}
100% {
background-color: #ff4500;
}
}
<span class="ticket">Ticket shape with transparent holes punched!</span>
<br />
<br />
<p>Based on Lea Verou's faux inset border-radius technique.</p>
What I want is move the circles to the top left and bottom left of the div.
The problem
The problem is that the first background is being displayed over the top of the second background, you can move the position of the circle but it is hidden.
To fix
You can achieve this by making the following changes:
background-size: 51% 100%; to background-size: 100% 50%; to make the background take up half of the height instead of the width
background-position: top left, top right; to background-position: top left, bottom left; to position the backgrounds at the top and bottom
background-image: radial-gradient(circle at 0 50%, rgba(255,255,224,0) 0.4em, #ffffe0 0.5em), radial-gradient(circle at 100% 50%, rgba(255,255,224,0) 0.4em, #ffffe0 0.5em); to background-image: radial-gradient(circle at 0 0, rgba(255, 255, 224, 0) 0.4em, #ffffe0 0.5em), radial-gradient(circle at 0 100%, rgba(255, 255, 224, 0) 0.4em, #ffffe0 0.5em); to position the radial gradient at the top and bottom of the backgrounds
* {
box-sizing: border-box;
}
body {
padding: 2em;
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
text-align: center;
background-color: #ff4500;
-webkit-animation: bg 10s linear infinite alternate;
animation: bg 10s linear infinite alternate;
color: rgba(0, 0, 0, 0.25);
font-size: 13px;
}
a {
color: rgba(0, 0, 0, 0.35);
}
.ticket {
display: inline-block;
box-sizing: content-box;
-webkit-filter: drop-shadow(0 2px 5px rgba(0, 0, 0, 0.5));
filter: drop-shadow(0 2px 5px rgba(0, 0, 0, 0.5));
position: relative;
height: 1em;
padding: 1em;
color: #000;
font-size: 16px;
background-size: 100% 50%;
background-repeat: no-repeat;
background-image: radial-gradient(circle at 0 0, rgba(255, 255, 224, 0) 0.4em, #ffffe0 0.5em), radial-gradient(circle at 0 100%, rgba(255, 255, 224, 0) 0.4em, #ffffe0 0.5em);
background-position: top left, bottom left;
}
#-webkit-keyframes bg {
0% {
background-color: #ff4500;
}
50% {
background-color: #b0e0e6;
}
100% {
background-color: #ff4500;
}
}
#keyframes bg {
0% {
background-color: #ff4500;
}
50% {
background-color: #b0e0e6;
}
100% {
background-color: #ff4500;
}
}
<span class="ticket">Ticket shape with transparent holes punched!</span>
<br />
<br />
<p>Based on Lea Verou's faux inset border-radius technique.</p>
you can use the below property for positioning change.
background-image radial-gradient(circle at 0 50%, rgba($bg,0) $hole, $bg ($hole + .1em)), radial-gradient(circle at 100% 50%, rgba($bg,0) $hole, $bg ($hole + .1em))

CSS3 sliding gradient animation - how it works

Following code produces sliding gradient animation without any line of javascript code:
html {
height: 100%
}
body {
height: 100%;
margin: 0
}
#keyframes loading {
from {
background-position: -5000% 0, 0 0
}
to {
background-position: 5000% 0, 0 0
}
}
.skeleton {
height: 100%;
animation-name: loading;
animation-duration: 1.5s;
animation-iteration-count: infinite;
background-color: #fff;
background-repeat: no-repeat;
background-image: linear-gradient(90deg, hsla(0, 0%, 100%, 0), hsla(0, 0%, 100%, .8) 50%, hsla(0, 0%, 100%, 0)), linear-gradient(#e5e5e5 100%, transparent 0);
background-size: 99% 100%;
}
<div class="skeleton"></div>
I experimented with some properties and still do not understand how it works. Especially, when background-size: 99% 100%; is changed to background-size: 100% 100%; animation slides in opposite direction!
Could you explain it?
I don't know what's your browser and its version. But on my computer, if background-size: 100% 100% then the animation will be stop. (Actually, the background-position will be ignored)
The idea of this trick is moving background-image (linear-gradient) by background-position. (Check the comment in code below for detail)
About your second question, you should refer this answer CSS background-position ignored when using background-size. A quick summary, you can't use percent for background-position if background-size reaches to 100%. This happens because the image in background has no space to move.
If you insist to use background-size with 100%. I afraid you have to use absolute values.
BTW, I've upgraded the code. Now it looks better.
html {
height: 100%
}
body {
height: 100%;
margin: 0
}
#keyframes loading {/* original code */
from {/* This is the position of image of the first frame */
background-position: -5000% 0, 0 0
}
to {/* This is the pos of img of the last frame */
background-position: 5000% 0, 0 0
}
}
#keyframes betterLoading {
0% {/* This is the position of image of the first frame */
background-position: -5000% 0, 0 0
}
50% {
/* This is the pos of img of a frame in the middle happening animation */
/* If duration is 1s then the pos below will be at 0.5s */
background-position: 5000% 0, 0 0
}
100% {/* This is the pos of img of the last frame */
background-position: -5000% 0, 0 0
}
}
.skeleton {
height: 100%;
animation-name: betterLoading;
animation-duration: 1.5s;
animation-iteration-count: infinite;
background-color: #fff;
background-repeat: no-repeat;
background-image: linear-gradient(90deg, hsla(0, 0%, 100%, 0), hsla(0, 0%, 100%, .8) 50%, hsla(0, 0%, 100%, 0)), linear-gradient(green 100%, transparent 0);
background-size: 99% 100%, cover;
}
<div class="skeleton"></div>

Button not getting positioned

body {
background-image: url("http://www.nozeens.com/wp-content/uploads/2014/11/White-Wallpaper-Pattern-Hd-Background-8-HD-Wallpapers.jpg");
}
.button {
margin-top: 100px;
position: relative;
background: -webkit-linear-gradient(left top, #FF6600, #FFCC00);
/* Green */
border: none;
color: white;
padding: 15px 32px;
text-align: center;
text-decoration: none;
font-size: 16px;
margin: 4px 2px;
cursor: pointer;
-webkit-transition-duration: 0.4s;
/* Safari */
transition-duration: 4s;
}
#-webkit-keyframes color-change {
0% {
background: -webkit-linear-gradient(left top, #005C66, #008A19);
}
25% {
background: -webkit-linear-gradient(left top, #CC66FF, #990099);
}
50% {
background: -webkit-linear-gradient(left top, #FF8C9E, #FFF2C7);
}
75% {
background: -webkit-linear-gradient(left top, #00A3C7, #00C7B5);
}
100% {
background: -webkit-linear-gradient(left top, #ABFF54, #75FF8A);
}
}
.button2:hover {
height: 250px;
min-width: 200px;
font-size: 75px;
font-family: american captain;
box-shadow: 0 12px 16px 0 rgba(0, 0, 0, 0.24), 0 17px 50px 0 rgba(0, 0, 0, 0.19);
transform: rotate(360deg);
animation: color-change 4s ease infinite;
}
<button class="button button2">Hover Me For Fun</button>
I created this animated button with the animations i just learnt but I can't seem to position it i even tried putting margin-top but it didn't work. At first I thought that it was because of position so I changed it to relative but it is still not working. Any help would be highly appreciated. Thanks :-)