CSS3 Tranisition Box Shadow Pulse - css

I'm trying to ensure that only the box shadow has the pulsate and not the whole button.
The experience should see the button solid but with the box shadow fading in and out if that makes sense.
Here is my code:
.gps_ring {
border: 3px solid #999;
-webkit-border-radius: 30px;
height: 42px;
width: 180px;
background-color: blue;
text-align: center;
display: block;
color: white;
box-shadow: 0 0 17px black;
-moz-box-shadow: 0 0 17px black;
-webkit-box-shadow: 0 0 17px black;
-webkit-animation: pulsate 1s ease-out;
-webkit-animation-iteration-count: infinite;
opacity: 0.0
}
#-webkit-keyframes pulsate {
0% {-webkit-transform: scale(0.1, 0.1); opacity: 0.0;}
50% {opacity: 1.0;}
100% {-webkit-transform: scale(1.2, 1.2); opacity: 0.0;}
}
EXAMPLE

Simply animate only the shadow, like this
.gps_ring {
border: 3px solid #999;
border-radius: 30px;
height: 42px;
width: 180px;
background-color: blue;
text-align: center;
display: block;
color: white;
box-shadow: 0 0 17px black;
animation: pulsate 1s ease-out infinite;
}
#-webkit-keyframes pulsate {
0% { box-shadow: 0 0 0 black; }
50% { box-shadow: 0 0 17px black; }
100% { box-shadow: 0 0 0 black; }
}
<div id="state" class="grid_4 alpha">
Touch me
</div>

I think this is what you need. Better solution http://codepen.io/governorfancypants/pen/zvMxWm
<div class="circle">
<div class="inner-circle"></div>
<div class="cover-circle"></div>
</div>
.pulsating-circle {
position: absolute;
left: 50%;
top: 50%;
transform: translateX(-50%) translateY(-50%);
width: 30px;
height: 30px;
&:before {
content: '';
position: relative;
display: block;
width: 300%;
height: 300%;
box-sizing: border-box;
margin-left: -100%;
margin-top: -100%;
border-radius: 45px;
background-color: #01a4e9;
animation: pulse-ring 1.25s cubic-bezier(0.215, 0.61, 0.355, 1) infinite;
}
&:after {
content: '';
position: absolute;
left: 0;
top: 0;
display: block;
width: 100%;
height: 100%;
background-color: white;
border-radius: 15px;
box-shadow: 0 0 8px rgba(0,0,0,.3);
animation: pulse-dot 1.25s cubic-bezier(0.455, 0.03, 0.515, 0.955) -.4s infinite;
}
}
#keyframes pulse-ring {
0% {
transform: scale(.33);
}
80%, 100% {
opacity: 0;
}
}
#keyframes pulse-dot {
0% {
transform: scale(.8);
}
50% {
transform: scale(1);
}
100% {
transform: scale(.8);
}
}

HTML
<span class="pulse"></span>
CSS
.pulse {
margin:80px;
display: block;
width: 100px;
height: 100px;
border-radius: 50%;
background: #cca92c;
cursor: pointer;
box-shadow: 0 0 0 rgba(0,0,0, 0.4);
animation: none;
}
.pulse:hover {
animation: pulse 2s infinite;
}
#-webkit-keyframes pulse {
0% {
-webkit-box-shadow: 0 0 0 0 rgba(0,0,0, 0.5);
}
70% {
-webkit-box-shadow: 0 0 0 50px rgba(0,0,0, 0);
}
100% {
-webkit-box-shadow: 0 0 0 0 rgba(0,0,0, 0);
}
}
#keyframes pulse {
0% {
-moz-box-shadow: 0 0 0 0 rgba(0,0,0, 0.5);
box-shadow: 0 0 0 0 rgba(0,0,0, 0.4);
}
70% {
-moz-box-shadow: 0 0 0 50px rgba(0,0,0, 0);
box-shadow: 0 0 0 50px rgba(0,0,0, 0);
}
100% {
-moz-box-shadow: 0 0 0 0 rgba(0,0,0, 0);
box-shadow: 0 0 0 0 rgba(0,0,0, 0);
}
}
Hover effect.
CodePen: https://codepen.io/smith-harshan/pen/MWpGXeY
Hope this would be a help.

Related

The vh unit doesn't seem to work with transform: translateY

I have 2 half-page-sized overlays that translate the opposite ways to give the illusion that the screen is opening up. In addition, I want them to stop at about 8% from the viewport top or bottom and not disappear entirely. It doesn't really work with % because on mobile devices with bars and other UI they are get cut off. I have tried to use vh but it just disappears into the viewport edges.
/*default animations*/
.main-transition-overlay1 {
position: fixed;
background-color: black;
z-index: 10;
height: 50vh;
top: 0;
left: 0;
width: 100%;
animation-name: page-transition-top;
animation-duration: 750ms;
animation-timing-function: ease-in;
animation-fill-mode: forwards;
animation-delay: 2s;
border-bottom: 4px solid #fff;
color: #fff;
box-shadow: 0 0px 1.5px #99ffff, 0 0px 2.5px #99ffff, 0 0px 5.5px #99ffff, 0 0px 10px #0cbfe9, 0 0px 20px #0cbfe9, 0 0px 22px #0cbfe9, 0 0px 25px #0cbfe9, 0 0px 36px #0cbfe9;
}
#keyframes page-transition-top {
from {
transform: translateY(0);
}
to {
transform: translateY(-92vh);
}
}
.main-transition-overlay2 {
position: fixed;
background-color: black;
z-index: 10;
height: 50vh;
top: 50vh;
left: 0;
width: 100%;
animation-name: page-transition-bottom;
animation-duration: 750ms;
animation-timing-function: ease-in;
animation-fill-mode: forwards;
animation-delay: 2s;
border-top: 4px solid #fff;
color: #fff;
box-shadow: 0 0 1.5px #99ffff, 0 0 2.5px #99ffff, 0 0 5.5px #99ffff, 0 0 10px #0cbfe9, 0 0 20px #0cbfe9, 0 0 22px #0cbfe9, 0 0 25px #0cbfe9, 0 0 36px #0cbfe9;
}
#keyframes page-transition-bottom {
from {
transform: translateY(0);
}
to {
transform: translateY(92vh);
}
}
<!--main screen transition overlay-->
<div>
<div class="main-transition-overlay1"></div>
<div class="main-transition-overlay2"></div>
</div>
Your transform value for that should be translateY(42vh) (and -42vh) instead of +/-92vh, that's the amount the elements move up/down:
/*default animations*/
.main-transition-overlay1 {
position: fixed;
background-color: black;
z-index: 10;
height: 50vh;
top: 0;
left: 0;
width: 100%;
animation-name: page-transition-top;
animation-duration: 750ms;
animation-timing-function: ease-in;
animation-fill-mode: forwards;
animation-delay: 2s;
border-bottom: 4px solid #fff;
color: #fff;
box-shadow: 0 0px 1.5px #99ffff, 0 0px 2.5px #99ffff, 0 0px 5.5px #99ffff, 0 0px 10px #0cbfe9, 0 0px 20px #0cbfe9, 0 0px 22px #0cbfe9, 0 0px 25px #0cbfe9, 0 0px 36px #0cbfe9;
}
#keyframes page-transition-top {
from {
transform: translateY(0);
}
to {
transform: translateY(-42vh);
}
}
.main-transition-overlay2 {
position: fixed;
background-color: black;
z-index: 10;
height: 50vh;
top: 50vh;
left: 0;
width: 100%;
animation-name: page-transition-bottom;
animation-duration: 750ms;
animation-timing-function: ease-in;
animation-fill-mode: forwards;
animation-delay: 2s;
border-top: 4px solid #fff;
color: #fff;
box-shadow: 0 0 1.5px #99ffff, 0 0 2.5px #99ffff, 0 0 5.5px #99ffff, 0 0 10px #0cbfe9, 0 0 20px #0cbfe9, 0 0 22px #0cbfe9, 0 0 25px #0cbfe9, 0 0 36px #0cbfe9;
}
#keyframes page-transition-bottom {
from {
transform: translateY(0);
}
to {
transform: translateY(42vh);
}
}
<!--main screen transition overlay-->
<div>
<div class="main-transition-overlay1"></div>
<div class="main-transition-overlay2"></div>
</div>

Is there a way to pause a specific CSS3 animation

I want to do something like the code below does but instead of having it "teleport" to the center I wish I could pause just one animation and keep the others running, in other words the element should stop wherever it is because the pass animation is paused, but the anim and force-stop animations should start running.
body {
background: #121212;
overflow: hidden;
}
.input {
transition: 100ms ease;
position: relative;
width: 100px;
height: 100px;
background: transparent;
border: 1.2px solid #383838;
border-radius: 10px;
margin: 0 auto;
top: 200px;
text-align: center;
}
.input .blaster {
position: absolute;
transition: 100ms ease;
background: #fff;
width: 100px;
height: 10px;
margin: 30% auto;
filter: blur(3px);
border-radius: 50%;
animation: anim 2s ease infinite,pass 500ms linear infinite;
top: -150px;
}
.input > span {
transition: 100ms ease;
position: relative;
top: 40px;
color: #aaa;
}
.input:hover {
animation: move 100ms ease infinite;
border-color: #eee;
background-color: #272727;
}
.input:hover > .blaster {
animation: anim 2s ease infinite,move 100ms ease infinite;
}
.input:hover > span {
color: transparent;
}
#keyframes anim {
from {
box-shadow: 0 0 5px 2px #fff,0px 0px 10px 3px #f33,0 0 15px 3px #f33;
}
50% {
box-shadow: 0 0 5px 2px #fff,0px 0px 16px 3px #f33,0 0 15px 5px #f33;
}
to {
box-shadow: 0 0 5px 2px #fff,0px 0px 10px 3px #f33,0 0 15px 3px #f33;
}
}
#keyframes pass {
from {
transform: translateX(-600px);
}
to {
transform: translateX(600px);
}
}
#keyframes move {
from {
transform: translateX(0px);
}
25% {
transform: translateX(2.24px);
}
75% {
transform: translateX(-1.75px);
}
to {
transform: translateX(0px);
}
}
<div class="input">
<span>Hover me</span>
<div class="blaster"></div>
</div>
I tried using animation-play-state but it pauses all animations.
Also I would prefer to do this in pure SCSS/CSS3 if possible but if there is a simple way to do it in JavaScript or jQuery it's acceptable too.
Thanks in advance!
UPDATE: I've made some janky styles in that snippet so unfortunately it only works in full-page.
Consider animation-play-state by simply writing:
.input:hover > .blaster {
animation-play-state:running,paused;
}
Full code
body {
background: #121212;
overflow: hidden;
}
.input {
transition: 100ms ease;
position: relative;
width: 100px;
height: 100px;
background: transparent;
border: 1.2px solid #383838;
border-radius: 10px;
margin: 0 auto;
top: 200px;
text-align: center;
}
.input .blaster {
position: absolute;
transition: 100ms ease;
background: #fff;
width: 100px;
height: 10px;
margin: 30% auto;
filter: blur(3px);
border-radius: 50%;
animation: anim 2s ease infinite,pass 500ms linear infinite;
top: -150px;
}
.input > span {
transition: 100ms ease;
position: relative;
top: 40px;
color: #aaa;
}
.input:hover {
animation: move 100ms ease infinite;
border-color: #eee;
background-color: #272727;
}
.input:hover > .blaster {
animation-play-state:running,paused;
}
.input:hover > span {
color: transparent;
}
#keyframes anim {
from {
box-shadow: 0 0 5px 2px #fff,0px 0px 10px 3px #f33,0 0 15px 3px #f33;
}
50% {
box-shadow: 0 0 5px 2px #fff,0px 0px 16px 3px #f33,0 0 15px 5px #f33;
}
to {
box-shadow: 0 0 5px 2px #fff,0px 0px 10px 3px #f33,0 0 15px 3px #f33;
}
}
#keyframes pass {
from {
transform: translateX(-600px);
}
to {
transform: translateX(600px);
}
}
#keyframes move {
from {
transform: translateX(0px);
}
25% {
transform: translateX(2.24px);
}
75% {
transform: translateX(-1.75px);
}
to {
transform: translateX(0px);
}
}
<div class="input">
<span>Hover me</span>
<div class="blaster"></div>
</div>

overflow absolute positioned psuedo element of a relative positioned parent set to overflow:hidden

I'm making a skull wearing a hat via CSS (jolly roger) which can be found at this codepen.
In the hat section, the lower edge of it has to be overflowed out of the parent div while the stripe in hat has to have overflow:hidden.
You may open the codepen link in both firefox and chrome to spot the difference.
While my code works fine in Firefox, this doesn't seem to work in chrome. I've tried many solutions that tells about how to position absolute items in a relative parent with overflow:hidden but none of those seem to work. Maybe I'm missing something important.
HTML
<div class="skull">
<div class="skull__face skull__face--animate">
<div class="skull__upper">
<div class="skull__hat"></div>
<div class="skull__nose"></div>
</div>
<div class="skull__lower">
<div class="skull__jaw"></div>
</div>
</div>
<div class="skull__bone skull__bone--left"></div>
<div class="skull__bone skull__bone--right"></div>
</div>
CSS
.skull__upper, .skull__lower {
background-color: white;
border: 7px solid black;
display: flex;
}
.skull__lower::before, .skull__jaw::before, .skull__jaw::after {
content: "";
width: 7px;
height: 6rem;
background-color: black;
display: inline-block;
position: absolute;
bottom: -1.6rem;
left: 0px;
right: 0px;
margin: auto;
}
#-webkit-keyframes boneDance {
0% {
-webkit-transform-origin: 49% 0%;
transform-origin: 49% 0%;
}
50% {
-webkit-transform-origin: 50% 0%;
transform-origin: 50% 0%;
}
100% {
-webkit-transform-origin: 51% 0%;
transform-origin: 51% 0%;
}
}
#keyframes boneDance {
0% {
-webkit-transform-origin: 49% 0%;
transform-origin: 49% 0%;
}
50% {
-webkit-transform-origin: 50% 0%;
transform-origin: 50% 0%;
}
100% {
-webkit-transform-origin: 51% 0%;
transform-origin: 51% 0%;
}
}
#-webkit-keyframes skullDance {
0% {
-webkit-transform: rotate(1deg);
transform: rotate(1deg);
}
50% {
-webkit-transform: rotate(0deg);
transform: rotate(0deg);
}
100% {
-webkit-transform: rotate(-1deg);
transform: rotate(-1deg);
}
}
#keyframes skullDance {
0% {
-webkit-transform: rotate(1deg);
transform: rotate(1deg);
}
50% {
-webkit-transform: rotate(0deg);
transform: rotate(0deg);
}
100% {
-webkit-transform: rotate(-1deg);
transform: rotate(-1deg);
}
}
#-webkit-keyframes blink {
from {
opacity: 0.4;
}
to {
opacity: 1;
}
}
#keyframes blink {
from {
opacity: 0.4;
}
to {
opacity: 1;
}
}
body {
background-color: #191919;
}
#media only screen and (max-width: 600px) {
body {
font-size: 12px;
}
}
.skull {
display: flex;
justify-content: center;
align-items: center;
margin-top: 10vh;
}
.skull__face {
display: flex;
flex-direction: column;
align-items: center;
z-index: 50;
position: relative;
}
.skull__face::after {
content: "";
width: 13rem;
border-radius: 50%;
box-shadow: 0px 0px 12rem 0 white;
position: absolute;
display: block;
height: 100%;
opacity: 0;
transition: opacity 1s ease-in-out;
}
.skull__face--animate:hover {
-webkit-animation: skullDance 1s steps(3) infinite alternate;
animation: skullDance 1s steps(3) infinite alternate;
cursor: none;
}
.skull__face--animate:hover::after {
opacity: 1;
-webkit-animation: blink 1s linear infinite alternate;
animation: blink 1s linear infinite alternate;
}
.skull__face--animate:hover ~ .skull__bone {
-webkit-animation: boneDance 1s steps(3) infinite alternate;
animation: boneDance 1s steps(3) infinite alternate;
}
.skull__upper {
width: 20rem;
height: 20rem;
border-radius: 50%;
z-index: 50;
position: relative;
}
.skull__upper::before, .skull__upper::after {
content: "";
display: block;
}
.skull__upper::before {
position: absolute;
border-radius: 50%;
box-shadow: 5.5rem 13.5rem 0px 2.8rem black, 14.5rem 13.5rem 0px 2.8rem black;
width: 1px;
height: 1px;
background-color: transparent;
}
.skull__hat {
justify-content: center;
background-color: #FFD020;
width: 20rem;
height: 10rem;
z-index: 45;
border-top-left-radius: calc(10rem + 7px);
border-top-right-radius: calc(10rem + 7px);
overflow: hidden;
}
.skull__hat::before, .skull__hat::after {
content: "";
display: block;
left: 0px;
right: 0px;
margin: auto;
}
.skull__hat::after {
height: 1rem;
background-color: #FFD020;
position: absolute;
border: 7px solid black;
border-radius: 1rem;
width: 30rem;
left: -5.5rem;
}
.skull__hat::before {
width: 18.5rem;
height: 0;
position: relative;
border-bottom: 3rem solid #FF0012;
border-left: 0.75rem solid transparent;
border-right: 0.75rem solid transparent;
margin-top: 5.35rem;
box-shadow: 0px 0px 0px 0px #191919, 0px -7px 0px 0px black;
}
.skull__lower {
width: 14rem;
height: 16rem;
border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
z-index: 49;
margin-top: -7rem;
overflow: hidden;
position: relative;
}
.skull__lower::before {
bottom: 4.5rem;
z-index: 40;
}
.skull__nose {
width: 3rem;
height: 2rem;
background: black;
border-radius: 50%;
position: absolute;
bottom: 2rem;
left: 0px;
right: 0px;
margin: auto;
}
.skull__jaw {
width: 21rem;
height: 21rem;
border-radius: 50%;
border: 7px solid black;
position: absolute;
margin: auto;
top: -12.5rem;
left: -4rem;
box-shadow: 0px 1.8rem 0px 0px white, 0px 2.2rem 0px 0px black;
}
.skull__jaw::before {
margin-left: 6.6rem;
-webkit-transform: rotate(10deg);
transform: rotate(10deg);
}
.skull__jaw::after {
margin-right: 6.6rem;
-webkit-transform: rotate(-10deg);
transform: rotate(-10deg);
}
.skull__bone {
background: white;
height: 3rem;
width: 36rem;
position: absolute;
border: 7px solid black;
-webkit-transform-origin: 50% 0%;
transform-origin: 50% 0%;
}
.skull__bone::before, .skull__bone::after {
content: "";
position: absolute;
border-radius: 50%;
top: -1.5rem;
width: 3rem;
height: 3rem;
background: white;
}
.skull__bone::before {
left: -1.5rem;
}
.skull__bone::after {
right: -1.5rem;
}
.skull__bone--left {
-webkit-transform: rotate(-45deg);
transform: rotate(-45deg);
}
.skull__bone--left::before {
box-shadow: 0 3rem 0 white, -2px 3.1rem 0px 2px black, -2px -0.1rem 0px 2px black;
}
.skull__bone--left::after {
box-shadow: 0 3rem 0 white, 3px 3.1rem 0px 1px black, 2px -0.1rem 0px 2px black;
}
.skull__bone--right {
-webkit-transform: rotate(45deg);
transform: rotate(45deg);
}
.skull__bone--right::before {
box-shadow: 0 3rem 0 white, -2px 3.1rem 0px 2px black, -2px -0.1rem 0px 2px black;
}
.skull__bone--right::after {
box-shadow: 0 3rem 0 white, 3px 3.1rem 0px 1px black, 2px -0.1rem 0px 2px black;
}
Any suggestions to make it work at least in Firefox and Chrome.
Just removing the z-index from the .skull__hat class did the trick.
.skull__upper, .skull__lower {
background-color: white;
border: 7px solid black;
display: flex;
}
.skull__lower::before, .skull__jaw::before, .skull__jaw::after {
content: "";
width: 7px;
height: 6rem;
background-color: black;
display: inline-block;
position: absolute;
bottom: -1.6rem;
left: 0px;
right: 0px;
margin: auto;
}
#-webkit-keyframes boneDance {
0% {
-webkit-transform-origin: 49% 0%;
transform-origin: 49% 0%;
}
50% {
-webkit-transform-origin: 50% 0%;
transform-origin: 50% 0%;
}
100% {
-webkit-transform-origin: 51% 0%;
transform-origin: 51% 0%;
}
}
#keyframes boneDance {
0% {
-webkit-transform-origin: 49% 0%;
transform-origin: 49% 0%;
}
50% {
-webkit-transform-origin: 50% 0%;
transform-origin: 50% 0%;
}
100% {
-webkit-transform-origin: 51% 0%;
transform-origin: 51% 0%;
}
}
#-webkit-keyframes skullDance {
0% {
-webkit-transform: rotate(1deg);
transform: rotate(1deg);
}
50% {
-webkit-transform: rotate(0deg);
transform: rotate(0deg);
}
100% {
-webkit-transform: rotate(-1deg);
transform: rotate(-1deg);
}
}
#keyframes skullDance {
0% {
-webkit-transform: rotate(1deg);
transform: rotate(1deg);
}
50% {
-webkit-transform: rotate(0deg);
transform: rotate(0deg);
}
100% {
-webkit-transform: rotate(-1deg);
transform: rotate(-1deg);
}
}
#-webkit-keyframes blink {
from {
opacity: 0.4;
}
to {
opacity: 1;
}
}
#keyframes blink {
from {
opacity: 0.4;
}
to {
opacity: 1;
}
}
body {
background-color: #191919;
}
#media only screen and (max-width: 600px) {
body {
font-size: 12px;
}
}
.skull {
display: flex;
justify-content: center;
align-items: center;
margin-top: 10vh;
}
.skull__face {
display: flex;
flex-direction: column;
align-items: center;
z-index: 50;
position: relative;
}
.skull__face::after {
content: "";
width: 13rem;
border-radius: 50%;
box-shadow: 0px 0px 12rem 0 white;
position: absolute;
display: block;
height: 100%;
opacity: 0;
transition: opacity 1s ease-in-out;
}
.skull__face--animate:hover {
-webkit-animation: skullDance 1s steps(3) infinite alternate;
animation: skullDance 1s steps(3) infinite alternate;
cursor: none;
}
.skull__face--animate:hover::after {
opacity: 1;
-webkit-animation: blink 1s linear infinite alternate;
animation: blink 1s linear infinite alternate;
}
.skull__face--animate:hover ~ .skull__bone {
-webkit-animation: boneDance 1s steps(3) infinite alternate;
animation: boneDance 1s steps(3) infinite alternate;
}
.skull__upper {
width: 20rem;
height: 20rem;
border-radius: 50%;
z-index: 50;
position: relative;
}
.skull__upper::before, .skull__upper::after {
content: "";
display: block;
}
.skull__upper::before {
position: absolute;
border-radius: 50%;
box-shadow: 5.5rem 13.5rem 0px 2.8rem black, 14.5rem 13.5rem 0px 2.8rem black;
width: 1px;
height: 1px;
background-color: transparent;
}
.skull__hat {
justify-content: center;
background-color: #FFD020;
width: 20rem;
height: 10rem;
border-top-left-radius: calc(10rem + 7px);
border-top-right-radius: calc(10rem + 7px);
overflow: hidden;
}
.skull__hat::before, .skull__hat::after {
content: "";
display: block;
left: 0px;
right: 0px;
margin: auto;
}
.skull__hat::after {
height: 1rem;
background-color: #FFD020;
position: absolute;
border: 7px solid black;
border-radius: 1rem;
width: 30rem;
left: -5.5rem;
}
.skull__hat::before {
width: 18.5rem;
height: 0;
position: relative;
border-bottom: 3rem solid #FF0012;
border-left: 0.75rem solid transparent;
border-right: 0.75rem solid transparent;
margin-top: 5.35rem;
box-shadow: 0px 0px 0px 0px #191919, 0px -7px 0px 0px black;
}
.skull__lower {
width: 14rem;
height: 16rem;
border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
z-index: 49;
margin-top: -7rem;
overflow: hidden;
position: relative;
}
.skull__lower::before {
bottom: 4.5rem;
z-index: 40;
}
.skull__nose {
width: 3rem;
height: 2rem;
background: black;
border-radius: 50%;
position: absolute;
bottom: 2rem;
left: 0px;
right: 0px;
margin: auto;
}
.skull__jaw {
width: 21rem;
height: 21rem;
border-radius: 50%;
border: 7px solid black;
position: absolute;
margin: auto;
top: -12.5rem;
left: -4rem;
box-shadow: 0px 1.8rem 0px 0px white, 0px 2.2rem 0px 0px black;
}
.skull__jaw::before {
margin-left: 6.6rem;
-webkit-transform: rotate(10deg);
transform: rotate(10deg);
}
.skull__jaw::after {
margin-right: 6.6rem;
-webkit-transform: rotate(-10deg);
transform: rotate(-10deg);
}
.skull__bone {
background: white;
height: 3rem;
width: 36rem;
position: absolute;
border: 7px solid black;
-webkit-transform-origin: 50% 0%;
transform-origin: 50% 0%;
}
.skull__bone::before, .skull__bone::after {
content: "";
position: absolute;
border-radius: 50%;
top: -1.5rem;
width: 3rem;
height: 3rem;
background: white;
}
.skull__bone::before {
left: -1.5rem;
}
.skull__bone::after {
right: -1.5rem;
}
.skull__bone--left {
-webkit-transform: rotate(-45deg);
transform: rotate(-45deg);
}
.skull__bone--left::before {
box-shadow: 0 3rem 0 white, -2px 3.1rem 0px 2px black, -2px -0.1rem 0px 2px black;
}
.skull__bone--left::after {
box-shadow: 0 3rem 0 white, 3px 3.1rem 0px 1px black, 2px -0.1rem 0px 2px black;
}
.skull__bone--right {
-webkit-transform: rotate(45deg);
transform: rotate(45deg);
}
.skull__bone--right::before {
box-shadow: 0 3rem 0 white, -2px 3.1rem 0px 2px black, -2px -0.1rem 0px 2px black;
}
.skull__bone--right::after {
box-shadow: 0 3rem 0 white, 3px 3.1rem 0px 1px black, 2px -0.1rem 0px 2px black;
}
<div class="skull">
<div class="skull__face skull__face--animate">
<div class="skull__upper">
<div class="skull__hat"></div>
<div class="skull__nose"></div>
</div>
<div class="skull__lower">
<div class="skull__jaw"></div>
</div>
</div>
<div class="skull__bone skull__bone--left"></div>
<div class="skull__bone skull__bone--right"></div>
</div>

Add border to scaling circles animation

I'm implementing waves animation similar to this:
I want to make the 2px border for each transparent wave circle - what is the best way to achieve this (preferably without width/height animation)?
Currently I'm animating box-shadow property and seems I'm unable(?) to use several shadows to imitate the border as long as I need them to be half-transparent. Also I'm unable to use scale as border-width will be scaled as well. The only way I see here is to animate the actual width/height of each <i> element but I don't think this animation will be smooth on all devices(?)
:root {
--size: 6px;
--duration: 1000ms;
}
body {
background: #333;
}
.blinker {
left: 50%;
top: 50%;
transform: translateX(-50%) translateY(-50%);
position: absolute;
z-index: 3;
background: #fdfdf9;
width: var(--size);
height: var(--size);
border-radius: 50%;
}
.blinker i {
position: absolute;
left: 50%;
top: 50%;
transform: translateX(-50%) translateY(-50%);
content: "";
width: 6px;
height: 6px;
border-radius: 50%;
opacity: 1;
}
.blinker i:nth-child(1) {
animation: blinkBoxShadow var(--duration) ease-out infinite;
display: block;
border: 1px solid white;
}
#keyframes blinkBoxShadow {
from {
box-shadow: 0 0 0 30px trasparent;
background: transparent;
opacity: 1;
}
to {
box-shadow: 0 0 0 30px rgba(255, 255, 255, 0.7);
background: rgba(255, 255, 255, 0.7);
opacity: 0;
}
}
.blinker i:nth-child(2) {
transform: translateX(-50%) translateY(-50%);
width: 61px;
height: 61px;
animation: blinkBoxShadow2 var(--duration) ease-out infinite;
animation-delay: calc(var(--duration) - 200ms);
}
#keyframes blinkBoxShadow2 {
from {
box-shadow: 0 0 0 0px rgba(255, 179, 117, 0.7);
opacity: 0;
}
50% {
opacity: 0.5;
}
to {
box-shadow: 0 0 0 50px rgba(255, 179, 117, 0);
opacity: 0;
}
}
.blinker i:nth-child(3) {
background: white;
}
<div class="blinker">
<i></i>
<i></i>
<i></i>
</div>
If I'm understanding correctly - You can't use box-shadow property, because of it's non-transparent?
If yes, you can set the color of the shadow by using rgba() function, where the last parameter is alpha (transparency) channel value. You can see how it's done on CodePen projects when you type in search bar - 'pulse'.
If no, if you would use JS to animate width/height I think it wouldn't be a efficiency problem on most mobile devices.
I think border should work. Remove box-shadow and animate it on width and height.
See the Snippet below:
:root {
--size: 6px;
--duration: 1000ms;
}
body {
background: #333;
}
.blinker {
left: 50%;
top: 50%;
transform: translateX(-50%) translateY(-50%);
position: absolute;
z-index: 3;
background: #fdfdf9;
width: var(--size);
height: var(--size);
border-radius: 50%;
}
.blinker i {
position: absolute;
left: 50%;
top: 50%;
transform: translateX(-50%) translateY(-50%);
content: "";
width: 6px;
height: 6px;
border-radius: 50%;
opacity: 1;
}
.blinker i:nth-child(1) {
animation: blinkBoxShadow var(--duration) ease-out infinite;
display: block;
border: 2px solid rgba(255, 255, 255, 0.5);
}
#keyframes blinkBoxShadow {
from {
/*box-shadow: 0 0 0 30px trasparent;*/
background: transparent;
opacity: 1;
width:0px;
height:0px;
}
to {
/*box-shadow: 0 0 0 30px rgba(255, 255, 255, 0.7);*/
background: rgba(255, 255, 255, 0.7);
opacity: 0;
width:61px;
height:61px;
}
}
.blinker i:nth-child(2) {
transform: translateX(-50%) translateY(-50%);
width: 61px;
height: 61px;
animation: blinkBoxShadow2 var(--duration) ease-out infinite;
animation-delay: calc(var(--duration) - 500ms);
}
#keyframes blinkBoxShadow2 {
from {
/*box-shadow: 0 0 0 0px rgba(255, 179, 117, 0.7);*/
background:transparent;
opacity: 0;
border:2px solid rgba(255, 179, 117, 0);
width: 61px;
height: 61px;
}
50% {
opacity: 0.5;
}
to {
/*box-shadow: 0 0 0 50px rgba(255, 179, 117, 0);*/
background:rgba(255, 179, 117, 0.2);
opacity: 0;
width:140px;
height:140px;
border:2px solid rgba(255, 179, 117, 0.2);
}
}
.blinker i:nth-child(3) {
background: white;
}
<div class="blinker">
<i></i>
<i></i>
<i></i>
</div>

Responsive circle based on it's content

I have this example JSFIDDLE contains a circle, but I'm having trouble to make it responsive according to it's content, in the above example when the content is long, it overflows the circle.
.cd-single-point {
margin:50px;
position: absolute;
border-radius: 50%;
}
.cd-single-point > a {
position: relative;
text-align:center;
padding:2px;
text-decoration: none;
z-index: 2;
display: block;
width: 20px;
height: 20px;
border-radius: inherit;
background: #d95353;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.3);
-webkit-transition: background-color 0.2s;
-moz-transition: background-color 0.2s;
transition: background-color 0.2s;
}
.cd-single-point::after {
/* this is used to create the pulse animation */
content: '';
position: absolute;
z-index: 1;
width: 100%;
height: 100%;
top: 0;
left: 0;
border-radius: inherit;
background-color: transparent;
-webkit-animation: cd-pulse 2s infinite;
-moz-animation: cd-pulse 2s infinite;
animation: cd-pulse 2s infinite;
}
How can I achieve this only with css?
You could use the padding technique on a pseudo element to keep the aspect ratio of the circle and make it responsive according to it's content :
DEMO
HTML :
<div class="wrap">
<div class="in">+46546546</div>
</div>
CSS :
.wrap{
color: #fff;
position:relative;
display:inline-block;
}
.in{
padding:60% 10%;
margin-top:-0.6em;
}
.in:after{
content:'';
position:absolute;
top:0; left:0;
width:120%;
padding-bottom:120%;
background-color:#D95353;
border-radius:50%;
z-index:-1;
}
How about this fiddle? http://jsfiddle.net/ctwheels/bgut7411/9/
HTML
<ul>
<li>
<div class="cd-single-point"> <a class="cd-img-replace" href="#">
<div class="takeNumber">+99</div>
</a>
</div>
</li>
<!-- .cd-single-point -->
</ul>
CSS
/* --------------------------------
Primary style
-------------------------------- */
html * {
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
body {
font-size: 100%;
font-family:"Roboto", sans-serif;
color: #33435a;
background-color: #3c4f6a;
}
.cd-single-point {
margin:50px;
position: absolute;
border-radius: 50%;
}
.cd-single-point > a {
position: relative;
text-align:center;
padding:5px;
text-decoration: none;
z-index: 2;
display: block;
min-width: 20px;
min-height: 20px;
border-radius: inherit;
background: #d95353;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.3);
-webkit-transition: background-color 0.2s;
-moz-transition: background-color 0.2s;
transition: background-color 0.2s;
}
.cd-single-point::after {
/* this is used to create the pulse animation */
content:'';
position: absolute;
z-index: 1;
width: 100%;
height: 100%;
top: 0;
left: 0;
border-radius: inherit;
background-color: transparent;
-webkit-animation: cd-pulse 2s infinite;
-moz-animation: cd-pulse 2s infinite;
animation: cd-pulse 2s infinite;
}
#-webkit-keyframes cd-pulse {
0% {
-webkit-transform: scale(1);
box-shadow: inset 0 0 5px 5px rgba(217, 83, 83, 0.8);
}
50% {
box-shadow: inset 0 0 1px 1px rgba(217, 83, 83, 0.8);
}
100% {
-webkit-transform: scale(1.6);
box-shadow: inset 0 0 1px 1px rgba(217, 83, 83, 0);
}
}
#-moz-keyframes cd-pulse {
0% {
-moz-transform: scale(1);
box-shadow: inset 0 0 1px 1px rgba(217, 83, 83, 0.8);
}
50% {
box-shadow: inset 0 0 1px 1px rgba(217, 83, 83, 0.8);
}
100% {
-moz-transform: scale(1.6);
box-shadow: inset 0 0 1px 1px rgba(217, 83, 83, 0);
}
}
#keyframes cd-pulse {
0% {
-webkit-transform: scale(1);
-moz-transform: scale(1);
-ms-transform: scale(1);
-o-transform: scale(1);
transform: scale(1);
box-shadow: inset 0 0 1px 1px rgba(217, 83, 83, 0.8);
}
50% {
box-shadow: inset 0 0 1px 1px rgba(217, 83, 83, 0.8);
}
100% {
-webkit-transform: scale(1.6);
-moz-transform: scale(1.6);
-ms-transform: scale(1.6);
-o-transform: scale(1.6);
transform: scale(1.6);
box-shadow: inset 0 0 1px 1px rgba(217, 83, 83, 0);
}
}
.takeNumber {
color:white;
font-family:Verdana;
font-size:12px;
padding-top:3px;
}
JS
var numItems = $(".cd-single-point").length;
var myHeight, myWidth;
for (i = 0; i < numItems; i++) {
myWidth = $(".cd-single-point>a:eq(" + i + ")").width();
myHeight = $(".cd-single-point>a:eq(" + i + ")").height();
if (myWidth > myHeight) {
$(".cd-single-point>a:eq(" + i + ")").css({
height: myWidth + "px"
});
}
if (myWidth < myHeight) {
$(".cd-single-point:eq(" + i + ")>a").css({
width: myHeight + "px"
});
}
$(".takeNumber:eq(" + i + ")").css({
"line-height": myWidth - parseInt($(".cd-single-point>a:eq(" + i + ")").css("padding"), 10) + "px"
});
}
If you're not opposed to some javascript you could check the width of the contents and then set an equivalent height.
$(function(){
var elementWidth = $(".takeNumber").width();
$(".cd-img-replace").css("height", elementWidth);
});
FIDDLE
Demo
css
.cd-single-point {
height: 30px;
min-width: 30px;
width: auto;
line-height: 30px;
text-align: center;
margin:50px;
position: absolute;
border-radius: 50%;
}
.cd-single-point > a {
display: block;
height: 30px;
min-width: 30px;
width: auto;
line-height: 30px;
text-align: center;
position: relative;
text-decoration: none;
z-index: 2;
border-radius: inherit;
background: #d95353;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.3);
-webkit-transition: background-color 0.2s;
-moz-transition: background-color 0.2s;
transition: background-color 0.2s;
}
.takeNumber {
color:white;
font-family:Verdana;
font-size:12px;
padding: 0 5px;
}

Resources