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>
Related
I want to animate the waves to go up when i click on the div i cant get the wave to animate when i change the heigt on the animation it self.
.tsx
<div className={styles.circle}>
<div className={styles.wave}></div>
</div>
.css
.circle {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-190%, -50%);
width: 25%;
height: 60%;
background: #ccc;
box-shadow: 0 0 0 5px #fff;
border-radius: 50%;
overflow: hidden;
}
.wave {
position: relative;
width: 100%;
height: 100%;
background: #4973ff;
border-radius: 50%;
box-shadow: inset 0 0 50px rgba(0, 0, 0, 0.5);
}
.wave:before,
.wave:after {
content: "";
position: absolute;
width: 200%;
height: 200%;
top: 0;
left: 50%;
transform: translate(-50%, -75%);
background: #000;
}
.wave:before {
border-radius: 45%;
background: rgb(255, 255, 255);
animation: animate 5s linear infinite;
}
.wave:after {
border-radius: 40%;
background: rgb(255, 255, 255, 0.5);
animation: animate 10s linear infinite;
}
#keyframes animate {
0% {
transform: translate(-50%, var(--water)) rotate(0deg);
}
100% {
transform: translate(-50%, var(--water)) rotate(360deg);
}
}
I tried putting translate: transform 2s linear but that didnt work for me eighter do you guys have any idea beaces when i change the
:root {
--water: -90%
}
to
:root {
--water: -80%
}
it will just snap and not animate
I'm working on a CSS slider animation.
Everything is pretty much done apart from one last thing:
The wanted behaviour is that if I hover over the slider thumb, the slider grows in height and the value moves in the centre of the slider. This works as expected, however when the slider thumb goes underneath the newly positioned value, it goes back to the previous size (basically reverting the animation).
I think that I need some sort of "pass-through", so that basically even if I'm not technically hovering on the slider, the value doesn't interfere at all with my animation.
I know, it is not clear at all, that's why I'm including a codepen to help you better understand what I mean. Change the slider and stop it at 29. Then try sliding again and you will see the wrong effect and what I mean.
https://codepen.io/NickHG/pen/NYOoXR?editors=0110
I'm also posting the code here for future reference: (note: is done using LESScss):
#temp0-14: #185fb6;
#temp15-19: #00bcd4;
#temp20-23: #ffc107;
#temp24-31: #ef6b52;
#gaps: 8, 4, 4, 15;
#temps: #temp24-31, #temp20-23,#temp15-19, #temp0-14;
#darkText: #000;
#lightText: #fff;
#percentage: 20%;
#desaturate-percentage: 40%;
.gaps-loop(#i, #prevgap) when (#i > 0) {
#gap: extract(#gaps, #i);
#temp: extract(#temps, #i);
.span-gen-loop(#j) when (#j < #gap) {
#k: #j + #prevgap;
.temp-#{k} {
display: block;
background: #temp;
color: contrast(#temp, #darkText, #lightText, #percentage);
&:hover {
//background: darken(#temp, 8%);
}
}
.temp-color-#{k} {
color: contrast(#temp, #darkText, #lightText, #percentage);
}
.span-gen-loop(#j + 1);
}
.span-gen-loop(0);
.gaps-loop(#i - 1, #prevgap + #gap);
}
.gaps-loop(length(#gaps), 0);
.animate-color-change {
transition: background 0.8s ease;
}
/* Slider custom style */
#entryHeight: 60px;
#sliderTrackHeight: 25px;
#sliderThumbHeight: #sliderTrackHeight;
#sliderThumbWidth: 25px;
.entry-external-container {
font-family: "Roboto", sans-serif;
height: #entryHeight;
min-height: #entryHeight;
width: 100%;
max-width: 400px;
display: block;
border: 1px solid black;
display: flex;
align-items: flex-end;
padding: 0;
margin: 0;
position: relative;
.dataName {
display: block;
width: 100%;
position: absolute;
top: 0;
transform: translateY(50%);
padding-left: 10px;
z-index: 2;
animation-timing-function: ease-out;
animation: dataNameIn 0.4s forwards;
}
.dataValue {
display: block;
width: 25px;
position: absolute;
top: 0;
text-align: right;
right: 10px;
transform: translateY(50%);
padding-right: 10px;
z-index: 2;
animation-timing-function: ease-in-out;
animation: dataValueZoomOut 0.1s forwards;
}
.slidecontainer {
width: 100%;
box-sizing: content-box;
.custom-slider {
-webkit-appearance: none;
appearance: none;
width: 100%;
height: #sliderTrackHeight;
outline: none;
opacity: 0.7;
margin: 0;
animation: sliderAnimationBackgroundOut 0.3s;
&::-webkit-slider-thumb {
-webkit-appearance: none;
appearance: none;
width: #sliderThumbWidth;
height: #sliderThumbHeight;
background: white;
cursor: pointer;
transition: height 0.25s, box-shadow 0.4s;
border: 1px solid rgba(0, 0, 0, 0.6);
box-sizing: border-box;
border-radius: 3px;
}
&:hover,
&:active {
&~.dataName {
animation: dataNameOut 0.4s forwards;
}
&~.dataValue {
animation: dataValueZoomIn 0.4s forwards;
&:hover{pointer-events:none;}
}
animation: sliderAnimationBackgroundIn 0.3s forwards;
&::-webkit-slider-thumb {
border-radius: 0px 3px 3px 0;
height: #entryHeight;
box-sizing: border-box;
border-right: 1px solid rgba(0, 0, 0, 0.5);
border-top: 1px solid rgba(0, 0, 0, 0.5);
border-bottom: 1px solid rgba(0, 0, 0, 0.5);
border-left: none;
-webkit-box-shadow: -7px 0px 7px -2px rgba(0, 0, 0, 0.2);
-moz-box-shadow: -7px 0px 7px -2px rgba(0, 0, 0, 0.2);
box-shadow: -7px 0px 7px -2px rgba(0, 0, 0, 0.2);
background: -webkit-gradient(
linear,
-20 0,
100% 0,
from(transparent),
to(white),
color-stop(80%, white)
);
}
}
}
}
}
#keyframes sliderAnimationBackgroundIn {
0% {
opacity: 0.7;
height: #sliderTrackHeight;
}
100% {
opacity: 1;
height: #entryHeight;
}
}
#keyframes sliderAnimationBackgroundOut {
0% {
opacity: 1;
height: #entryHeight;
}
100% {
opacity: 0.7;
height: #sliderTrackHeight;
}
}
#keyframes dataNameOut {
0% {opacity: 1;top: 0}
20% {opacity: 0;top: -15px}
100% {top: -40px;opacity: 0}
}
#keyframes dataNameIn {
0% {top: -40px;opacity: 0}
20% {opacity: 0;top: -15px}
100% {opacity: 1;top: 0}
}
#keyframes dataValueZoomIn {
0% { transform: scale(1); top: 5px; right: 7.5px;}
25% { transform: scale(1.2); top: 10px; right: 10px;}
50% { transform: scale(1.3); top: 15px;right: 11px;}
75% { transform: scale(1.4); top: 20px;right: 13px;}
100% { transform: scale(1.5);top: 20px;right: 13.7px;}
}
#keyframes dataValueZoomOut {
100% { transform: scale(1); top: 5px; right: 7.5px;}
75% { transform: scale(1.2); top: 10px; right: 10px;}
50% { transform: scale(1.3); top: 15px;right: 11px;}
25% { transform: scale(1.4); top: 20px;right: 13px;}
0% { transform: scale(1.5);top: 20px;right: 13.7px;}
}
use pointer-events to prevent an element from being hovered :
The pointer-events CSS property specifies under what circumstances (if
any) a particular graphic element can become the target of mouse
events.
.dataValue {
pointer-events: none;
}
PEN
You could achieve the same effect setting the hover state to the parent.
PEN
.slidecontainer {
width: 100%;
box-sizing: content-box;
&:hover {
.custom-slider {
...
}
}
}
Note: Is not a good practice to nest more than 3 levels deep,
How can I make the last part of the spinner lighter (ie. fading):
#loader-wrapper {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: 1000;
}
#loader {
display: block;
position: relative;
left: 50%;
top: 50%;
width: 150px;
height: 150px;
margin: -75px 0 0 -75px;
border-radius: 50%;
border: 5px solid transparent;
border-top-color: #aaa;
border-right-color: #aaa;
animation: spin 2s linear infinite;
}
#keyframes spin {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
<div id="loader-wrapper">
<div id="loader"></div>
</div>
I tried using gradient but it converts it to a square
You can apply the gradient to a pseudo-element like so:
#loader-wrapper {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: 1000;
}
#loader {
display: block;
position: relative;
left: 50%;
top: 50%;
width: 150px;
height: 150px;
margin: -75px 0 0 -75px;
border-radius: 50%;
border: 5px solid transparent;
border-top-color: #aaa;
border-right-color: #aaa;
animation: spin 2s linear infinite;
}
#loader::after {
content: '';
width: 85%;
height: 85%;
background: linear-gradient(45deg, rgba(255, 255, 255, 1) 0%, rgba(255, 255, 255, 1) 40%, rgba(255, 255, 255, 0.7) 60%, rgba(255, 255, 255, 0) 100%);
position: absolute;
top: 0;
left: 0;
transform: translate(-5%, -5%);
}
#keyframes spin {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
<div id="loader-wrapper">
<div id="loader"></div>
</div>
Here is another idea with less code and without using pseudo element.
.loader {
--border-width: 5px;
height: 150px;
width: 150px;
border-radius: 50%;
/* 0.5px's are needed to avoid hard-stopping */
--mask: radial-gradient(
farthest-side,
transparent calc(100% - var(--border-width) - 0.5px),
#000 calc(100% - var(--border-width) + 0.5px)
);
-webkit-mask: var(--mask);
mask: var(--mask);
background: linear-gradient(#aaa 30%, transparent 80%) 0 0/50% 100% no-repeat; /* this is our border image */
animation: spin 2s linear infinite;
}
#keyframes spin {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
<div class="loader"></div>
And this is the comparison of my answer with #Ricky's answer by setting background to body:
#Ricky's way:
body {
background: pink; /* just added this */
}
#loader-wrapper {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: 1000;
}
#loader {
display: block;
position: relative;
left: 50%;
top: 50%;
width: 150px;
height: 150px;
margin: -75px 0 0 -75px;
border-radius: 50%;
border: 5px solid transparent;
border-top-color: #aaa;
border-right-color: #aaa;
animation: spin 2s linear infinite;
}
#loader::after {
content: '';
width: 85%;
height: 85%;
background: linear-gradient(45deg, rgba(255, 255, 255, 1) 0%, rgba(255, 255, 255, 1) 40%, rgba(255, 255, 255, 0.7) 60%, rgba(255, 255, 255, 0) 100%);
position: absolute;
top: 0;
left: 0;
transform: translate(-5%, -5%);
}
#keyframes spin {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
<div id="loader-wrapper">
<div id="loader"></div>
</div>
My way:
body {
background: pink; /* just added this */
}
.loader {
--border-width: 5px;
height: 150px;
width: 150px;
border-radius: 50%;
/* 0.5px's are needed to avoid hard-stopping */
--mask: radial-gradient(
farthest-side,
transparent calc(100% - var(--border-width) - 0.5px),
#000 calc(100% - var(--border-width) + 0.5px)
);
-webkit-mask: var(--mask);
mask: var(--mask);
background: linear-gradient(#aaa 30%, transparent 80%) 0 0/50% 100% no-repeat; /* this is our border image */
animation: spin 2s linear infinite;
}
#keyframes spin {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
<div class="loader"></div>
I have a code font-icon animation my problem is when i run in local server animation does'nt works it works only in http://codepen.io/TimPietrusky/pen/ELuiG
and even tried in
http://jsfiddle.net/qjo7cf3j/
#import url(http://weloveiconfonts.com/api/?family=maki);
html,
body {
height: 100%;
width: 100%;
overflow: hidden;
background: #333;
}
[class*="maki-"]:before{
font-family: 'maki', sans-serif;
}
*:after {
position: absolute;
top: 0;
right: 0;
content: '';
z-index: -1;
width: 0;
height: 0;
}
[class*="maki-"] {
position: absolute;
margin: 0;
color: #fff;
font-size: 2em;
}
.wrapper {
height: 140%;
width: 120%;
transform: rotate(-3deg) translate(-10%, -15%);
}
.night {
position: absolute;
z-index: 5;
width: 100%;
height: 100%;
animation: night 45s infinite forwards;
}
#keyframes night {
0%, 30%, 100% {background:rgba(0, 0, 0, 0);}
55% {background: rgba(0, 0, 0, .6);}
}
.sky {
position: relative;
z-index: 0;
background: url(http://subtlepatterns.subtlepatterns.netdna-cdn.com/patterns/bedge_grunge.png);
height: 50%;
width: 100%;
animation: rollin-bg 25s linear infinite forwards;
}
.ground {
position: absolute;
z-index: 1;
background: url(http://subtlepatterns.subtlepatterns.netdna-cdn.com/patterns/blackorchid.png);
height: 50%;
width: 100%;
animation: rollin-bg 7s linear infinite forwards;
}
#keyframes rollin-bg {
0% {background-position: 100%;}
100% {background-position: 0;}
}
.sun {
position: absolute;
z-index: 1;
left: 50%;
top: 10%;
width: 2em;
height: 2em;
font-size: 4em;
line-height: 1;
animation: circle 45s linear infinite;
transform-origin: 50% 3.85em;
}
.sun [class*="maki-"] {
color: rgba(240, 180, 0, .2);
text-shadow: 0 0 .35em rgba(240, 240, 0, .7);
}
.sun > div {
animation: inner-circle 45s linear infinite;
}
#keyframes circle {
from { transform: rotate(0deg); }
to { transform: rotate(360deg); }
}
#keyframes inner-circle {
from { transform: rotate(0deg); }
to { transform: rotate(-360deg); }
}
.maki-bicycle {
left: 50%;
z-index: 4;
margin: -.85em 0 0 -.5em;
color: rgba(30, 30, 140, .95);
}
.maki-tree-1[data-child="1"] {
margin: -1em 0 0 5%;
z-index: 6;
animation: rollin 5s linear infinite;
font-size: 2.4em;
color: rgba(0, 110, 0, 1);
}
.maki-tree-1[data-child="2"] {
margin: -1em 0 0 85%;
z-index: 2;
animation: rollin 12s linear infinite;
font-size: 1.6em;
color: rgba(0, 110, 0, .5);
}
.maki-tree-1[data-child="3"] {
margin: -1em 0 0 25%;
z-index: 2;
animation: rollin 17s linear infinite;
font-size: 1.2em;
color: rgba(0, 110, 0, .3);
}
.maki-giraffe {
margin: .25em 0 0 5%;
z-index: 6;
animation: rollin 12s linear infinite reverse;
font-size: 10em;
color: rgba(255, 255, 10, .9);
}
.maki-giraffe:after {
right: -3em;
content: '\e82a \e82a \e82a \e82a \e82a';
font: .2em 'Maki', sans-serif;
letter-spacing: .2em;
width: 3em;
color: rgba(0, 0, 0, .6);
box-shadow:
0 .45em 0 .75em rgba(255, 255, 255, .4),
1em .35em 0 .75em rgba(255, 255, 255, .4),
2.25em .25em 0 1.05em rgba(255, 255, 255, .4)
;
border-radius: 50%;
transform: translate(2.3em, .55em) rotateY(-180deg);
}
.maki-grocery-store {
margin: -.35em 0 0 5%;
z-index: 5;
animation: rollin 22s linear infinite;
font-size: 4em;
color: rgba(220, 0, 10, .7);
}
.maki-commerical-building[data-child="1"] {
margin: -1em 0 0 5%;
z-index: 3;
animation: rollin 6s linear infinite;
font-size: 7em;
color: rgba(120, 0, 120, .8);
}
.maki-commerical-building[data-child="2"] {
margin: -1em 0 0 5%;
z-index: 2;
animation: rollin 14s linear infinite;
font-size: 4em;
color: rgba(0, 120, 120, .4);
}
.maki-heliport {
margin: -3.5em 0 0 2em;
z-index: 1;
color: rgba(30, 30, 30, .45);
font-size: 1.25em;
animation: rollin 26s linear infinite reverse 2s;
}
#keyframes rollin {
0% {margin-left:105%}
100% {margin-left:-15%;}
}
<div class="night"></div>
<div class="wrapper">
<div class="sun">
<div class="maki-fast-food"></div>
</div>
<div class="sky"></div>
<span class="maki-bicycle"></span>
<span class="maki-tree-1" data-child="1"></span>
<span class="maki-tree-1" data-child="2"></span>
<span class="maki-tree-1" data-child="3"></span>
<span class="maki-giraffe"></span>
<span class="maki-grocery-store"></span>
<span class="maki-commerical-building" data-child="1"></span>
<span class="maki-commerical-building" data-child="2"></span>
<span class="maki-heliport"></span>
<div class="ground"></div>
</div>
The reason why the animation doesn't work at all in your version, is because the animation properties need prefixes like -webkit- in some browsers.
In the CodePen, -prefix-free is used, which is why it works. It is a library that automatically adds the prefixed version of the CSS properties.
CodePen can also use Autoprefixer (another such library) or neither. Once you select 'neither', you'll see that the CodePen example also doesn't work anymore, because the (S)CSS doesn't contain the required prefixed version for the CSS attributes.
So, the solution: either use a library too, or add the required prefixed attributes for Chrome (and maybe other browsers too).
A similar issue (for a different set of properties) was asked for and answered here.
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;
}