ERROR font-icon animation works ONLY in code-pen - css

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.

Related

Perfect infinite rotation for ֍ character

Im trying to use this character
֍
in place of a loading spinner.
Here's what I've got so far:
.spinner::after {
animation: rotating 2s linear infinite;
content: "֍";
font-size: 60px;
display: inline-block;
font-weight: normal;
transform-origin: 50% 50%;
}
#keyframes rotating {
0% {
transform: rotate(0deg) scale(1);
color: rgba(0, 0, 0, .5);
}
50% {
transform: rotate(180deg) scale(.8);
color: rgba(0, 0, 0, .85);
}
100% {
transform: rotate(360deg);
color: rgba(0, 0, 0, .5);
}
}
<i class="spinner"></i>
Even though this works, it is not perfect because the rotation does currently not happen around the perfect center of the character despite
transform-origin: 50% 50%;
making it look less than stellar.
Any ideas how to fix this?
I would use a fixed height equal to the font-size then play with line-height until I get it right. Also no need to set transform-origin since by default it's set to center
.spinner::after {
content: "֍";
font-size: 60px;
font-weight: normal;
line-height: 0.8;
display: inline-block;
height: 60px;
animation: rotating 2s linear infinite;
}
#keyframes rotating {
0% {
transform: rotate(0deg) scale(1);
color: rgba(0, 0, 0, .5);
}
50% {
transform: rotate(180deg) scale(.8);
color: rgba(0, 0, 0, .85);
}
100% {
transform: rotate(360deg);
color: rgba(0, 0, 0, .5);
}
}
<i class="spinner"></i>
it happens because a character height and width are not equal...
I tried to increase the height until It does what you want..
and here is the result:
.spinner::after {
animation: rotating 2s linear infinite;
content: "֍";
height: 80px;
font-size: 60px;
display: inline-block;
font-weight: normal;
}
#keyframes rotating {
0% {
transform: rotate(0deg) scale(1);
color: rgba(0, 0, 0, .5);
}
50% {
transform: rotate(180deg) scale(.8);
color: rgba(0, 0, 0, .85);
}
100% {
transform: rotate(360deg);
color: rgba(0, 0, 0, .5);
}
}
<i class="spinner"></i>
Three Properties
line-height: 3;
transform-origin: 50% 54%;
text-align: center;
Demo
.spinner::after {
animation: spin 2s infinite linear;
content: "֍";
font-size: 5em;
display: inline-block;
font-weight: normal;
/* Required */
line-height: 3;
/* Required */
transform-origin: 50% 54%;
/* Required */
text-align: center;
/* Optional for Position */
position: relative;
width: 3em;
top: 0;
}
#keyframes spin {
0% {
transform: rotate(0deg) scale(1);
color: rgba(0, 0, 0, .5);
}
50% {
transform: rotate(180deg) scale(.8);
color: rgba(0, 0, 0, .85);
}
100% {
transform: rotate(360deg);
color: rgba(0, 0, 0, .5);
}
}
<i class="spinner"></i>
You will not get perfect center while rotating rectangle shape but you will get perfect center if its square shape
see demo below
div {
display: inline-block;
width: 100px;
height: 100px;
background-color: brown;
text-align: center;
position: relative;
margin: 10px;
float: left;
}
.spinner0::after {
animation: rotating 2s linear infinite;
content: "֍";
height: 80px;
font-size: 60px;
display: inline-block;
font-weight: normal;
}
#keyframes rotating {
0% {
transform: rotate(0deg) scale(1);
color: rgba(0, 0, 0, .5);
}
50% {
transform: rotate(180deg) scale(.8);
color: rgba(0, 0, 0, .85);
}
100% {
transform: rotate(360deg);
color: rgba(0, 0, 0, .5);
}
}
div > i:before {
content: '';
width: 5px;
height: 5px;
background-color: #000;
border-radius: 50%;
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
}
.spinner1::after{
animation: rotating 5s linear infinite;
content: "֍";
font-size: 60px;
line-height: 60px;
display: inline-block;
font-weight: normal;
position: absolute;
left: 50%;
top: 50%;
margin-top: -30px;
margin-left: -22px;
}
.spinner2::after {
animation: rotating 5s linear infinite;
content: "֍";
display: flex;
width: 100%;
height: 100%;
justify-content: center;
align-items: center;
font-size: 60px;
transform: rotate(90deg);
margin-left: 2px;
}
.spinner3::after {
animation: rotating 5s linear infinite;
content: "";
height: 30px;
width: 30px;
font-size: 60px;
line-height: 1;
display: inline-block;
font-weight: normal;
border: 1px solid #000;
position: absolute;
left: 50%;
top: 50%;
margin-top: -15px;
margin-left: -15px;
}
<div>
<i class="spinner1"></i>
</div>
<div>
<i class="spinner2"></i>
</div>
<div>
<i class="spinner3"></i>
</div>
if you still want to rotate rectangular shape/icon then along with rotation you have to adjust its position a bit
hope you got my point here

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>

CSS - Animation triggers back when mouse hover

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 do I delay the appearance of an animated scrolling background (CSS)?

I have a sequence of animations, each delayed to appear one after the other.
Sequence:
Logo
h1
hr
background starts scrolling upwards
Using animation-fill-mode: backwards each element does not appear on the page until it is animated-in. I would like the same to happen to the background. So it does not appear until all the other animations are complete. The background would then start scrolling upwards.
/*Top Gif*/
.banner {
position: relative;
float: left;
width: 100%;
height: 400px;
text-align: center;
}
.opening {
display: block;
background: url(http://subtlepatterns2015.subtlepatterns.netdna-cdn.com/patterns/footer_lodyas.png);
animation: 100s scroll infinite linear;
animation-delay: 3s;
animation-fill-mode: background;
margin: 2px 0 0 0;
}
.textBox {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
.logo {
width: 300px;
margin-bottom: 20px;
}
.logo--animated {
animation: popUp 1s ease-out;
}
.textBox h1 {
color: #FFF;
font-size: 60px;
text-shadow: 0px 4px 3px rgba(0, 0, 0, 0.4), 0px 8px 13px rgba(0, 0, 0, 0.1), 0px 18px 23px rgba(0, 0, 0, 0.1);
line-height: 50px;
animation: moveInRight 0.7s ease-out;
animation-delay: 1.2s;
animation-fill-mode: backwards;
}
hr.style-two {
border: 0;
height: 3px;
background-image: linear-gradient(to right, rgba(255, 255, 255, 0), rgba(255, 255, 255, 0.75), rgba(255, 255, 255, 0));
animation: moveInRight 0.4s ease-out;
animation-delay: 1.9s;
animation-fill-mode: backwards;
}
.textBox h4 {
line-height: 10px;
font-weight: normal;
font-size: 20px;
animation: moveInRight 0.6s ease-out;
animation-delay: 2.3s;
animation-fill-mode: backwards;
}
/*Animations*/
#keyframes scroll {
100% {
background-position: 0px -3000px;
}
}
#keyframes popUp {
0% {
opacity: 0;
transform: translateY(50px);
}
100% {
opacity: 1;
transform: translateY(0px);
}
}
#keyframes moveInRight {
0% {
opacity: 0;
transform: translateX(-80px);
}
100% {
opacity: 1;
transform: translate(0);
}
}
<div class="row">
<div class="col-lg-12">
<div class="banner opening">
<div class="opening">
<div class="textBox">
<img class="logo logo--animated" src="logo.png">
<h1>Title</h1>
<hr class="style-two">
<h4>Sub-Title</h4>
</div>
</div>
</div>
</div>
</div>
If you want the background to just appear, try this.
/*Top Gif*/
.banner {
position: relative;
float: left;
width: 100%;
height: 400px;
text-align: center;
}
.opening {
animation-delay: 5s;
display: block;
animation: 100s scroll infinite linear;
animation-delay: 3s;
animation-fill-mode: forwards;
margin: 2px 0 0 0;
}
.textBox {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
.logo {
width: 300px;
margin-bottom: 20px;
}
.logo--animated {
animation: popUp 1s ease-out;
}
.textBox h1 {
color: #FFF;
font-size: 60px;
text-shadow: 0px 4px 3px rgba(0, 0, 0, 0.4), 0px 8px 13px rgba(0, 0, 0, 0.1), 0px 18px 23px rgba(0, 0, 0, 0.1);
line-height: 50px;
animation: moveInRight 0.7s ease-out;
animation-delay: 1.2s;
animation-fill-mode: backwards;
}
hr.style-two {
border: 0;
height: 3px;
background-image: linear-gradient(to right, rgba(255, 255, 255, 0), rgba(255, 255, 255, 0.75), rgba(255, 255, 255, 0));
animation: moveInRight 0.4s ease-out;
animation-delay: 1.9s;
animation-fill-mode: backwards;
}
.textBox h4 {
line-height: 10px;
font-weight: normal;
font-size: 20px;
animation: moveInRight 0.6s ease-out;
animation-delay: 2.3s;
animation-fill-mode: backwards;
}
/*Animations*/
#keyframes scroll {
0% {
background-image: url(http://subtlepatterns2015.subtlepatterns.netdna-cdn.com/patterns/footer_lodyas.png);
}
100% {
background-image: url(http://subtlepatterns2015.subtlepatterns.netdna-cdn.com/patterns/footer_lodyas.png);
background-position: 0px -3000px;
}
}
#keyframes popUp {
0% {
opacity: 0;
transform: translateY(50px);
}
100% {
opacity: 1;
transform: translateY(0px);
}
}
#keyframes moveInRight {
0% {
opacity: 0;
transform: translateX(-80px);
}
100% {
opacity: 1;
transform: translate(0);
}
}
<div class="row">
<div class="col-lg-12">
<div class="banner opening">
<div class="opening">
<div class="textBox">
<img class="logo logo--animated" src="logo.png">
<h1>Title</h1>
<hr class="style-two">
<h4>Sub-Title</h4>
</div>
</div>
</div>
</div>
</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