Animation: jelly doesn't work - css

I've tried to create a button that animates to the left, and then back ti the right again, to it's normal state. Animation doesn't work with this code:
.fortnite-wrapper .btn.btn-display:after {
content: "";
display: block;
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 2em;
background-color: #ff0;
-webkit-transition: background-color .3s ease-in-out;
-o-transition: background-color .3s ease-in-out;
transition: background-color .3s ease-in-out;
-webkit-box-shadow: 0 4px 12px -4px rgba(0,0,0,.5);
box-shadow: 0 4px 12px -4px rgba(0,0,0,.5);
-webkit-animation: jelly 6s ease-in-out infinite;
animation: jelly 6s ease-in-out infinite;
-webkit-transform-origin: 50% 50% 20px;
-ms-transform-origin: 50% 50% 20px;
transform-origin: 50% 50% 20px;
}
Left side of the button should expand to the left for 20 px and then go back, animation is infinite.
HTML for button:
<div class="fortnite-wrapper">
<button class="btn download-button btn-primary btn-display play-free">
<span>Fortnite</span></button>
</div>

First off, you didn't define the animation jelly, which is needed to tell the element which properties to animate.
Secondly, animation-direction: alternate makes the animation reverse itself after completion. This is neccessary in order to keep the element from jumping back to the start. In this snippet I put it into animation: jelly 2s ease-in-out infinite alternate;.
.fortnite-wrapper {
position: relative;
width: 200px;
}
.fortnite-wrapper .btn.btn-display:after {
content: "";
display: block;
position: absolute;
top: 0;
right: 0;
width: 100%;
height: 2em;
background-color: #ff0;
-webkit-transition: background-color .3s ease-in-out;
-o-transition: background-color .3s ease-in-out;
transition: background-color .3s ease-in-out;
-webkit-box-shadow: 0 4px 12px -4px rgba(0, 0, 0, .5);
box-shadow: 0 4px 12px -4px rgba(0, 0, 0, .5);
-webkit-animation: jelly 2s ease-in-out infinite alternate;
animation: jelly 2s ease-in-out infinite alternate;
-webkit-transform-origin: 50% 50% 20px;
-ms-transform-origin: 50% 50% 20px;
transform-origin: 50% 50% 20px;
}
#keyframes jelly {
0 {
width: 100%;
}
100% {
width: calc(100% - 20px);
}
}
<div class="fortnite-wrapper">
<button class="btn download-button btn-primary btn-display play-free">
<span>Fortnite</span></button>
</div>
Edit: In order for the animation to only affect the left side of the block without changing the rest of it, I recommend animating the property width instead. If you use it in combination with position: absolute and right: 0 the element will in- and decrease in size on the left side.

.outer {
margin: 50px;
}
.button {
border: 1px solid black;
border-radius: 3px;
width: 100px;
height: 30px;
display: block;
background: linear-gradient(to right, black 50%, white 50%);
background-size: 200% 100%;
background-position: right bottom;
transition: all .5s ease-out;
}
.button:hover {
background-position: left bottom;
}
.text {
text-align: center;
font-size: 16px;
line-height: 30px;
color: black;
transition: all .6s ease-out;
display: block;
}
.text:hover {
color: white;
}
<div class="outer">
<div class="button">
<div class="text">button</div>
</div>
</div>

Related

Bounce card css animation

I'm building a very simple bounce card animation, however at some point the animation got reseted and the result is not fluent.
Please check:
div{
width: 110px;
height: 50px;
background: #EEE;
border: 1px solid #BBB;
border-radius: 3px;
padding: 3px 5px;
font-family: sans-serif;
left: 200px;
position: absolute;
}
#keyframes cardBouncing {
20%, 60%, to {
transform: rotate3d(0, 0, 1, 80deg);
transform-origin: top left;
animation-timing-function: ease-in-out;
}
0%, 40%, 80% {
transform: rotate3d(0, 0, 1, 60deg);
transform-origin: top left;
animation-timing-function: ease-in-out;
}
}
div{
box-shadow: 3px 3px 10px grey;
animation: 1.5s cardBouncing infinite; //flipInX;
}
<div>HOla!</div>
How I can make it bouncing without that "jump"
This is for a drag animation, how can I center in the mouse cursor position? It seems like it go to much at the left. It's possible?
The solution is with: animation-direction: alternate-reverse;
div{
width: 110px;
height: 50px;
background: #EEE;
border: 1px solid #BBB;
border-radius: 3px;
padding: 3px 5px;
font-family: sans-serif;
position: absolute;
left: 180px;
}
#keyframes cardBouncing {
from {
transform: rotate3d(0, 0, 1, 60deg);
transform-origin: top left;
animation-timing-function: ease-in-out;
}
to {
transform: rotate3d(0, 0, 1, 80deg);
transform-origin: top left;
animation-timing-function: ease-in-out;
}
}
div{
box-shadow: 3px 3px 10px grey;
animation: 0.4s cardBouncing infinite;
animation-direction: alternate-reverse;
}
<div> Hola! </div>

Overlay covers whole dive - but keep fonts white

I trying to change the brightess of a div (not only an image brightness). Generaly there is an image in a div, description and caption, the main div background color is white. I want to show ovarlay div onmouse hover. Idea is to cover main div with overlay div. But now I getting only the image brightness change , what I want to achieve is to cover the hole div and keep whithe fonts.
When I add a thumbnail brightness effect it also influence the fonts to became darker. how to do that keeping fonts white.
col-sm-6, caption, thumbnail classes are defined by bootstrap.
The code of:
<div class="hovereffect thumbnail Staffinview1 delay1s">
<img src="./images/photo.jpg">
<div class="overlay">
<?php echo Person_description; ?>
</div>
<div class="caption">
<h3>Name Surname</h3>
</div>
</div>
</div>
The css code:
.thumbnail:hover {
transition: all 0.5s ease-in-out;
-moz-transition: all 0.5s ease-in-out;
-webkit-transition: all 0.5s ease-in-out;
-o-transition: all 0.5s ease-in-out;
-ms-transition: all 0.5s ease-in-out;
box-shadow: 0 12px 16px 0 rgba(0,0,0,0.24), 0 17px 50px 0 rgba(0,0,0,0.5);
}
.hovereffect {
width: 100%;
height: 100%;
float: left;
overflow: hidden;
position: relative;
text-align: center;
cursor: default;
}
.hovereffect .overlay {
position: absolute;
overflow: hidden;
width: 80%;
height: 80%;
left: 10%;
top: 10%;
border-bottom: 1px solid #FFF;
border-top: 1px solid #FFF;
-webkit-transition: opacity 0.35s, -webkit-transform 0.35s;
transition: opacity 0.35s, transform 0.35s;
-webkit-transform: scale(0,1);
-ms-transform: scale(0,1);
transform: scale(0,1);
color: #fff;
}
.hovereffect:hover .overlay {
opacity: 1;
filter: alpha(opacity=100);
-webkit-transform: scale(1);
-ms-transform: scale(1);
transform: scale(1);
}
.hovereffect img {
display: block;
position: relative;
-webkit-transition: all 0.35s;
transition: all 0.35s;
}
.hovereffect:hover img{
filter: url('data:image/svg+xml;charset=utf-8,<svg xmlns="http://www.w3.org/2000/svg"><filter id="filter"><feComponentTransfer color-interpolation-filters="sRGB"><feFuncR type="linear" slope="0.6" /><feFuncG type="linear" slope="0.6" /><feFuncB type="linear" slope="0.6" /> </feComponentTransfer></filter></svg>#filter');
filter: brightness(0.3);
-webkit-filter: brightness(0.3);
}
I believe You are trying to achieve a mask
You can use z-index property and postion:absolute for that overlay div
css rule
.overlay {
position: absolute;
width: 100%;
height: 100%;
top: 0%;
z-index: 0;
transition: all 0.5s;
}
.overlay:hover {
z-index: 1;
background: rgb(173, 173, 173);
opacity: 0.5;
}
Snippet below
.thumbnail:hover {
transition: all 0.5s ease - in -out;
- moz - transition: all 0.5s ease - in -out;
- webkit - transition: all 0.5s ease - in -out;
- o - transition: all 0.5s ease - in -out;
- ms - transition: all 0.5s ease - in -out;
box - shadow: 0 12px 16px 0 rgba(0, 0, 0, 0.24), 0 17px 50px 0 rgba(0, 0, 0, 0.5);
}
.hovereffect {
width: 100 %;
height: 100 %;
float: left;
overflow: hidden;
position: relative;
text - align: center;
cursor: default;
}
.hovereffect.overlay {
position: absolute;
overflow: hidden;
width: 80 %;
height: 80 %;
left: 10 %;
top: 10 %;
border - bottom: 1px solid# FFF;
border - top: 1px solid# FFF;
- webkit - transition: opacity 0.35s, -webkit - transform 0.35s;
transition: opacity 0.35s, transform 0.35s;
- webkit - transform: scale(0, 1);
- ms - transform: scale(0, 1);
transform: scale(0, 1);
color: #fff;
}
.hovereffect:hover.overlay {
opacity: 1;
filter: alpha(opacity=100);
- webkit - transform: scale(1);
- ms - transform: scale(1);
transform: scale(1);
}
.hovereffect img {
display: block;
position: relative;
- webkit - transition: all 0.35s;
transition: all 0.35s;
}
.overlay {
position: absolute;
width: 100%;
height: 100%;
top: 0%;
z-index: 0;
transition: all 0.5s;
}
.overlay:hover {
z-index: 1;
background: rgb(173, 173, 173);
opacity: 0.5;
}
<div class="hovereffect thumbnail Staffinview1 delay1s">
<img src="./images/photo.jpg">
<div class="overlay">
<?php echo Person_description; ?>
</div>
<div class="caption">
<h3>Name Surname</h3>
</div>
</div>

How to reverse a sequence of CSS transitions and transforms which contain span:nth-child

This CSS "animation" in essence consist of several transitions and transforms on span:nth-children which follow each other sequentially using transition delays. It works fine one way, but what is the best way to reverse the animation? Since it is a sequence the solution should reverse the entire sequence. See fiddle for example:
http://jsfiddle.net/musicformellons/6nb0wy68/
#Pqb-icon {
background: white;
width: 170px;
height: 100px;
border-radius: 5px;
position: relative;
overflow: hidden;
border: 2px solid salmon;
border-bottom: 20;
-webkit-transition: .9s ease-in-out;
-moz-transition: .9s ease-in-out;
-o-transition: .9s ease-in-out;
transition: .9s ease-in-out;
}
#Pqb-icon span {
display: block;
position: absolute;
border: 5px solid black;
width: 20px;
height: 20px;
bottom: 50px;
left: 12%;
background: rgba(255, 200, 220, 0.4);
transition-timing-function: ease;
}
#Pqb-icon span:nth-child(1) {
left: 12%;
border-radius: 25px;
-webkit-transform-origin: left center;
-moz-transform-origin: left center;
-o-transform-origin: left center;
transform-origin: left center;
}
#Pqb-icon.open span:nth-child(1) {
left: 12%;
border-radius: 25px;
-webkit-transition: .25s ease-in-out;
-moz-transition: .25s ease-in-out;
-o-transition: .25s ease-in-out;
transition: .25s ease-in-out;
}
#Pqb-icon.open span:nth-child(3) {
left: 36%;
bottom: 50px;
border-radius: 25px;
-webkit-transform: translate(-40px,0px);
-moz-transform: translate(-40px,0px);
-o-transform: translate(-40px,0px);
transform: translate(-40px,0px);
-webkit-transition: .25s ease .7s;
-moz-transition: .25s ease .7s;
-o-transition: .25s ease .7s;
transition: .4s ease .9s;
opacity: 0;
}
#Pqb-icon span:nth-child(2) {
width: 5px;
height: 38%;
bottom: 27%;
background: black;
border: 0px solid black;
-webkit-transform-origin: left center;
-moz-transform-origin: left center;
-o-transform-origin: left center;
transform-origin: left center;
}
#Pqb-icon.open span:nth-child(2) {
width: 5px;
height: 38%;
bottom: 27%;
background: black;
border: 0px solid black;
-webkit-transition: .25s ease-in-out;
-moz-transition: .25s ease-in-out;
-o-transition: .25s ease-in-out;
transition: .25s ease;
}
#Pqb-icon.open span:nth-child(4) {
width: 5px;
height: 38%;
bottom: 27%;
left: 15%;
background: black;
border: 0px solid black;
-webkit-transform: rotateZ(-180deg);
-moz-transform: rotateZ(-180deg);
-o-transform: rotateZ(-180deg);
transform: rotate(-180deg) ;
-webkit-transition: .25s ease-in-out .7s;
-moz-transition: .25s ease-in-out .7s;
-o-transition: .25s ease-in-out .65s;
transition: .4s ease .8s;
opacity: 0;
}
#Pqb-icon span:nth-child(3) {
bottom: 27%;
left: 28.5%;
border-radius: 25px;
-webkit-transform-origin: left center;
-moz-transform-origin: left center;
-o-transform-origin: left center;
transform-origin: left center;
}
#Pqb-icon.open span:nth-child(5) {
bottom: 27%;
left: 46%;
border-radius: 25px;
-webkit-transform: rotateZ(-180deg);
-moz-transform: rotateZ(-180deg);
-o-transform: rotateZ(-180deg);
transform: rotateZ(-180deg) ;
-webkit-transition: .35s ease-in-out;
-moz-transition: .35s ease-in-out;
-o-transition: .35s ease-in-out;
transition: .4s ease .4s;
opacity: 0;
}
#Pqb-icon span:nth-child(4) {
width: 5px;
height: 32%;
bottom: 10%;
left: 43%;
background: black;
border: 0px solid black;
-webkit-transform-origin: left center;
-moz-transform-origin: left center;
-o-transform-origin: left center;
transform-origin: left center;
}
#Pqb-icon.open span:nth-child(6) {
width: 5px;
height: 32%;
bottom: 10%;
left: 46.5%;
background: black;
border: 0px solid black;
-webkit-transform: rotateZ(-180deg);
-moz-transform: rotateZ(-180dreg);
-o-transform: rotateZ(-180deg);
transform: rotateZ(-180deg) ;
-webkit-transition: .35s ease-in-out .35s;
-moz-transition: .35s ease-in-out .35s;
-o-transition: .35s ease-in-out .35s;
transition: .4s ease .4s;
opacity: 0;
}
#Pqb-icon span:nth-child(5) {
bottom: 27%;
left: 51%;
border-radius: 25px;
-webkit-transform-origin: left center;
-moz-transform-origin: left center;
-o-transform-origin: left center;
transform-origin: left center;
}
#Pqb-icon span:nth-child(6) {
width: 5px;
height: 35%;
bottom: 40%;
left: 51%;
background: black;
border: 0px solid black;
-webkit-transform-origin: left center;
-moz-transform-origin: left center;
-o-transform-origin: left center;
transform-origin: left center;
}
Since you are only using transition and already have the toggleClass method, you don't need to change anything in the JS to reverse the transition effect. All that you need to do is add a different transition setting to the default state (not with class='open') like the below snippet.
Essentially what we are doing is this:
The elements that are causing the effect are the third, fourth, fifth and sixth span elements.
Initially for the move out effect, the fifth and sixth span elements move out with a delay of .4s.
The third and fourth span elements move out with a delay of 0.8s (or 0.9s). This has an extra delay because it has to move out after the fifth and sixth are out of the way. The fifth and sixth spans will take 0.4s (transition duration) + 0.4s (transition delay) = 0.8s to complete.
On toggling the class off, we need this to happen in reverse. That is, the third and fourth span elements should move in to view at a delay of 0.4s while the fifth and sixth span should move in after a delay of 0.8s. So adding the appropriate transition settings to the following selectors would be enough:
#Pqb-icon span:nth-child(3) {transition: .4s ease .4s;}
#Pqb-icon span:nth-child(4) {transition: .4s ease .4s;}
#Pqb-icon span:nth-child(5) {transition: .4s ease .9s;}
#Pqb-icon span:nth-child(6) {transition: .4s ease .9s;}
Note: I have removed the vendor prefixes in the snippet and added the prefix library to keep the code small.
$('#Pqb-icon').on('click', function() {
$(this).toggleClass('open');
});
#Pqb-icon {
background: white;
width: 170px;
height: 100px;
border-radius: 5px; /*dikte van rondjes*/
position: relative;
overflow: hidden;
border: 2px solid salmon;
border-bottom: 20;
transition: .9s ease-in-out;
}
#Pqb-icon span {
display: block;
position: absolute;
border: 5px solid black;
width: 20px;
height: 20px;
bottom: 50px;
left: 12%;
background: rgba(255, 200, 220, 0.4);
transition-timing-function: ease;
}
/* BEFORE collapsed: hamburger */
#Pqb-icon span:nth-child(1) {
left: 12%;
border-radius: 25px;
transition: .25s ease-in-out;
transform-origin: left center;
}
#Pqb-icon.open span:nth-child(1) {
left: 12%;
border-radius: 25px;
}
#Pqb-icon span:nth-child(2) {
width: 5px;
height: 38%;
bottom: 27%;
background: black;
border: 0px solid black;
transition: .25s ease;
transform-origin: left center;
}
#Pqb-icon.open span:nth-child(2) {
width: 5px;
height: 38%;
bottom: 27%;
background: black;
border: 0px solid black;
}
#Pqb-icon span:nth-child(3) {
bottom: 27%;
left: 28.5%;
border-radius: 25px;
transition: .4s ease .4s;
transform-origin: left center;
}
#Pqb-icon.open span:nth-child(3) {
left: 36%;
bottom: 50px;
border-radius: 25px;
transition: .4s ease .9s;
transform: translate(-40px, 0px);
opacity: 0;
}
#Pqb-icon span:nth-child(4) {
width: 5px;
height: 32%;
bottom: 10%;
left: 43%;
background: black;
border: 0px solid black;
transition: .4s ease .4s;
transform-origin: left center;
}
#Pqb-icon.open span:nth-child(4) {
width: 5px;
height: 38%;
bottom: 27%;
left: 15%;
background: black;
border: 0px solid black;
transition: .4s ease .9s;
transform: rotate(-180deg);
opacity: 0;
}
#Pqb-icon span:nth-child(5) {
bottom: 27%;
left: 51%;
border-radius: 25px;
transition: .4s ease .9s;
transform-origin: left center;
}
#Pqb-icon.open span:nth-child(5) {
bottom: 27%;
left: 46%;
border-radius: 25px;
transition: .4s ease .4s;
transform: rotateZ(-180deg);
opacity: 0;
}
#Pqb-icon span:nth-child(6) {
width: 5px;
height: 35%;
bottom: 40%;
left: 51%;
background: black;
border: 0px solid black;
transition: .4s ease .9s;
transform-origin: left center;
}
#Pqb-icon.open span:nth-child(6) {
width: 5px;
height: 32%;
bottom: 10%;
left: 46.5%;
background: black;
border: 0px solid black;
transition: .4s ease .4s;
transform: rotateZ(-180deg);
opacity: 0;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/prefixfree/1.0.7/prefixfree.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<button type="button">
<span class="sr-only">Toggle navigation</span>
<div id="Pqb-icon">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</div>
</button>

Animate shadows css3?

I would like a css animation which creates this:
http://line25.com/wp-content/uploads/2010/text-shadow/demo/index.html#boardgame
But the shadows drop down from the top of the screen and fall into position...is this possible? If not what's the best way to achieve this sort of effect.
#boardgame h1 {
text-align: center;
margin: 200px auto;
font-family: "League-Gothic", Courier;
font-size: 200px; text-transform: uppercase;
color: #fff;
text-shadow: 10px 10px 0 #ffd217, 20px 20px 0 #5ac7ff, 30px 30px 0 #ffd217, 40px 40px 0 #5ac7ff;
}
You can set the text shadow on a pseudo element, and animate that:
body {
background-color: lightblue;
}
h1#boardgame {
text-align: center;
margin: 100px auto;
font-family: "League-Gothic", Courier;
font-size: 200px; text-transform: uppercase;
color: #fff;
position: relative;
}
h1:after {
position: absolute;
content: "My header";
left: 0px;
top: 0px;
width: 100%;
height: 100%;
color: transparent;
text-shadow: 10px 10px 0 #ffd217, 20px 20px 0 #5ac7ff, 30px 30px 0 #ffd217, 40px 40px 0 #5ac7ff;
z-index: -1;
-webkit-animation: slide 5s;
animation: slide 5s;
}
#-webkit-keyframes slide {
0% {-webkit-transform: translateY(-100%);}
100% {-webkit-transform: translateY(0%);}
}
#keyframes slide {
0% {transform: translateY(-100%);}
100% {transform: translateY(0%);}
}
fiddle
alternate fiddle
According to this answer, it is possible: https://stackoverflow.com/a/9540707/451962
#box {
width: 50px;
height: 200px;
-webkit-transition: all 1s linear;
-o-transition: all 1s linear;
-moz-transition: all 1s linear;
-ms-transition: all 1s linear;
-kthtml-transition: all 1s linear;
transition: all 1s linear;
}
.shadow {
-webkit-box-shadow: 0px 0px 4px 2px #D50E0E;
-moz-box-shadow: 0px 0px 4px 2px #D50E0E;
box-shadow: 0px 0px 4px 2px #D50E0E;
-webkit-transition: all 1s linear;
-o-transition: all 1s linear;
-moz-transition: all 1s linear;
-ms-transition: all 1s linear;
-kthtml-transition: all 1s linear;
transition: all 1s linear;
}
JS Fiddle demo.

CSS Wobble Animation

I'm trying to created a continuous wobble animation on a div id, and its not working for me. Any help would be greatly appreciated.
This is my code:
.figure {
display: inline-block;
width: 200px;
height: 200px;
background: rgb(23, 147, 219);
padding: 40px;
box-shadow: inset -5px -15px rgba(0, 0, 0, .06);
-moz-border-radius: 100px;
-webkit-border-radius: 100px;
border-radius: 50%;
animation: wobble 5s ease-in-out infinite;
transform-origin: center bottom;
transition: padding .3s, bottom .3s;
text-align: center;
}
#keyframes wobble {
33% {
transform: rotate(5deg);
}
66% {
transform: rotate(-5deg);
}
}
<div class="figure" ></div>
Actually it is working , but since it is a sphere you can't notice it rotating , remove border-radius to see it. Also use alternate to see better effect
animation:wobble 5s ease-in-out infinite alternate;
also use 0% to 100% animation for better result.

Resources