How to color the CSS loader? - html

I have working code for a CSS preloader at CSS preloader sample
I would like the animated preloader to be colored. I tried adding the style color: red !important; to various styles to the CSS class lds-ripple, but it did nothing.
A colored preloader would look more impressive in my view.
How would I make the CSS preloader show with colored rings?
the same code from working sample is also pasted below.
<button id="btnShow" onclick="showLoader()">Show Loader</button>
<div id="loader">
<div class="lds-ripple"><div></div><div></div></div>
</div>
<style>
#loader {
display: none;
justify-content: center;
align-items: center;
width:100%;
height:100%;
border:green solid 1 px;
opacity:0.9;
background-color:whitesmoke;
position:absolute;
left:0;
top:0;
}
.lds-ripple {
display: inline-block;
position: relative;
width: 80px;
height: 80px;
}
.lds-ripple div {
position: absolute;
border: 4px solid #fff;
opacity: 1;
border-radius: 50%;
animation: lds-ripple 1s cubic-bezier(0, 0.2, 0.8, 1) infinite;
}
.lds-ripple div:nth-child(2) {
animation-delay: -0.5s;
}
#keyframes lds-ripple {
0% {
top: 36px;
left: 36px;
width: 0;
height: 0;
opacity: 0;
}
4.9% {
top: 36px;
left: 36px;
width: 0;
height: 0;
opacity: 0;
}
5% {
top: 36px;
left: 36px;
width: 0;
height: 0;
opacity: 1;
}
100% {
top: 0px;
left: 0px;
width: 72px;
height: 72px;
opacity: 0;
}
}
</style>
<script>
function showLoader() {
document.getElementById("loader").style.display = "flex";
}
</script>

#fff in the line marked below can be changed to set the loader's color.
.lds-ripple div {
position: absolute;
border: 4px solid #fff; /* edit this line */
opacity: 1;
border-radius: 50%;
animation: lds-ripple 1s cubic-bezier(0, 0.2, 0.8, 1) infinite;
}
For example:
function showLoader() {
document.getElementById("loader").style.display = "flex";
}
showLoader();
#loader {
display: none;
justify-content: center;
align-items: center;
width:100%;
height:100%;
border:green solid 1 px;
opacity:0.9;
background-color:whitesmoke;
position:absolute;
left:0;
top:0;
}
.lds-ripple {
display: inline-block;
position: relative;
width: 80px;
height: 80px;
}
.lds-ripple div {
position: absolute;
border: 4px solid red;
opacity: 1;
border-radius: 50%;
animation: lds-ripple 1s cubic-bezier(0, 0.2, 0.8, 1) infinite;
}
.lds-ripple div:nth-child(2) {
animation-delay: -0.5s;
}
#keyframes lds-ripple {
0% {
top: 36px;
left: 36px;
width: 0;
height: 0;
opacity: 0;
}
4.9% {
top: 36px;
left: 36px;
width: 0;
height: 0;
opacity: 0;
}
5% {
top: 36px;
left: 36px;
width: 0;
height: 0;
opacity: 1;
}
100% {
top: 0px;
left: 0px;
width: 72px;
height: 72px;
opacity: 0;
}
}
<div id="loader">
<div class="lds-ripple"><div></div><div></div></div>
</div>

For changing color animation:
#keyframes lds-ripple {
0% {
top: 36px;
left: 36px;
width: 0;
height: 0;
opacity: 0;
border-color: red;
}
4.9% {
top: 36px;
left: 36px;
width: 0;
height: 0;
opacity: 0;
border-color: red;
}
5% {
top: 36px;
left: 36px;
width: 0;
height: 0;
opacity: 1;
border-color: red;
}
100% {
top: 0px;
left: 0px;
width: 72px;
height: 72px;
opacity: 0;
border-color: blue;
}
}
The problem is that the divs inside the lds-ripple have no dimension into it. So the color property won't have any effect. However, the border-color will still work. So you can replace the default #fff color with something like red. For example:
.lds-ripple div {
position: absolute;
border: 4px solid red; /* HERE */
opacity: 1;
border-radius: 50%;
animation: lds-ripple 1s cubic-bezier(0, 0.2, 0.8, 1) infinite;
}
function showLoader() {
document.getElementById("loader").style.display = "flex";
}
#loader {
display: none;
justify-content: center;
align-items: center;
width: 100%;
height: 100%;
border: green solid 1 px;
opacity: 0.9;
background-color: whitesmoke;
position: absolute;
left: 0;
top: 0;
}
.lds-ripple {
display: inline-block;
position: relative;
width: 80px;
height: 80px;
}
.lds-ripple div {
position: absolute;
border: 4px solid red; /* HERE */
opacity: 1;
border-radius: 50%;
animation: lds-ripple 1s cubic-bezier(0, 0.2, 0.8, 1) infinite;
}
.lds-ripple div:nth-child(2) {
animation-delay: -0.5s;
}
#keyframes lds-ripple {
0% {
top: 36px;
left: 36px;
width: 0;
height: 0;
opacity: 0;
border-color: red;
}
4.9% {
top: 36px;
left: 36px;
width: 0;
height: 0;
opacity: 0;
border-color: red;
}
5% {
top: 36px;
left: 36px;
width: 0;
height: 0;
opacity: 1;
border-color: red;
}
100% {
top: 0px;
left: 0px;
width: 72px;
height: 72px;
opacity: 0;
border-color: blue;
}
}
<button id="btnShow" onclick="showLoader()">Show Loader</button>
<div id="loader">
<div class="lds-ripple">
<div></div>
<div></div>
</div>
</div>

Related

How do I move the exit button below the fan?

Can you help me?
Currently the red exit button is on the spinning fan, I want to place it below it.
How do I do that in the code? https://jsfiddle.net/aqpoew6d/
I am trying to do this:
Image
.exit {
position: absolute;
top: 200px;
bottom: -47.63px;
margin: auto;
right: 0;
left: 0;
width: 47px;
height: 47px;
cursor: pointer;
border-radius: 100%;
background: transparent;
border: 5px solid red;
box-sizing: border-box;
opacity: 1;
clip-path: circle(50%);
}
.exit::before,
.exit::after {
content: "";
background-color: red;
width: 47px;
height: 5px;
position: absolute;
top: 0px;
left: -5px;
right: 0;
bottom: 0;
margin: auto;
}
.exit::before {
transform: rotate(45deg);
}
.exit::after {
transform: rotate(-45deg);
}
Image
html,
body {
height: 100%;
margin: 0;
padding: 0;
}
body {
background: gray;
}
.containerInitial {
position: absolute;
left: 0;
right: 0;
min-height: 100%;
min-width: 255px;
display: flex;
padding: 8px 8px;
}
.curtainInitial {
flex: 1 0 0;
margin: auto;
max-width: 680px;
border: 21px solid;
border-radius: 12px;
border-color: #000 #101010 #000 #101010;
position: relative;
overflow: hidden;
}
.curtainInitial::before {
content: '';
position: absolute;
top: -2px;
left: -2px;
right: -2px;
bottom: -2px;
background: #0a0a0a;
background: radial-gradient(circle, transparent 0% 48.5%, #0a0a0a 48.5%);
border: 1px solid;
border-color: #000 #101010 #000 #101010;
}
.curtainInitial::after {
content: "";
position: absolute;
left: 0;
right: 0;
bottom: 0;
top: 0;
outline: 1px solid green;
pointer-events: none;
}
.fence {
position: absolute;
left: 0;
top: 0;
bottom: 0;
right: 0;
margin: auto;
background:
linear-gradient(45deg,
#0000 7px,
#0a0a0a 0 7.5px,
#0000 0 10px),
linear-gradient(-45deg,
#0000 7px,
#0a0a0a 0 7.5px,
#0000 0 10px),
linear-gradient(to top, #e10019 0%, #957e00 100%);
background-size: 10px 10px,10px 10px, cover;
filter: drop-shadow(0 0 5px #000);
-webkit-animation: fade 5s infinite;
animation: fade 5s infinite;
clip-path: circle(34.5% at center);
}
.fence>div {
position: absolute;
/*top: 0;*/
left: 0;
right: 0;
/*width: 100%;*/
height: 0.55%;
/*height: 2px;*/
background: black;
}
.fence>div:nth-child(1) {
top: 9.8%;
}
.fence>div:nth-child(2) {
top: 19.2%;
}
.fence>div:nth-child(3) {
top: 28.6%;
}
.fence>div:nth-child(4) {
top: 38%;
}
.fence>div:nth-child(5) {
top: 47.4%;
}
.fence>div:nth-child(6) {
top: 56.8%;
}
.fence>div:nth-child(7) {
top: 66.2%;
}
.fence>div:nth-child(8) {
top: 75.6%;
}
.fence>div:nth-child(9) {
top: 85%;
}
.fence>div:nth-child(10) {
top: 94.4%;
}
.fan svg {
position: absolute;
top: 0;
left: 0;
bottom: 0;
right: 0;
width: 100%;
height: 100%;
margin: auto;
}
.cross {
clip-path: circle(34.5% at center);
position: absolute;
left: 0;
top: 0;
bottom: 0;
right: 0;
margin: auto;
width: 100%;
height: 100%;
background: transparent;
}
.cross::before,
.cross::after {
content: "";
position: absolute;
left: 0;
top: 0;
bottom: 0;
right: 0;
margin: auto;
background: black;
}
.cross::before
/*horizontal*/
{
height: 2.8%;
}
.cross::after
/*vertical*/
{
width: 1.4%;
}
.ratio-keeper {
position: relative;
height: 0;
padding-top: 56.25%;
margin: auto;
overflow: hidden;
}
.fan svg {
position: absolute;
top: 0;
left: 0;
bottom: 0;
right: 0;
margin: auto;
width: 100%;
height: 100%;
animation: fan-spin 40s infinite linear;
}
#keyframes fan-spin {
0% {
transform: scale(0.98) rotate(0deg);
}
100% {
transform: scale(0.98) rotate(360deg);
}
}
#-webkit-keyframes fade {
0% {
opacity: 0.9;
}
50% {
opacity: 1;
}
100% {
opacity: 0.9;
}
}
#keyframes fade {
0% {
opacity: 0.9;
}
50% {
opacity: 1;
}
100% {
opacity: 0.9;
}
}
iframe {
display: block;
animation: iframe 5s ease-in 5s forwards;
animation-delay: 1s;
opacity: 0;
}
#keyframes iframe {
to {
opacity: 1;
}
}
.embed-youtube iframe,
.embed-youtube .embed-youtube-play,
.embed-youtube .embed-youtube-play::before {
position: absolute;
}
.embed-youtube iframe {
height: 100%;
width: 100%;
top: 0;
left: 0;
}
.exit {
position: absolute;
top: 200px;
bottom: -47.63px;
margin: auto;
right: 0;
left: 0;
width: 47px;
height: 47px;
cursor: pointer;
border-radius: 100%;
background: transparent;
border: 5px solid red;
box-sizing: border-box;
opacity: 1;
clip-path: circle(50%);
}
.exit::before,
.exit::after {
content: "";
background-color: red;
width: 47px;
height: 5px;
position: absolute;
top: 0px;
left: -5px;
right: 0;
bottom: 0;
margin: auto;
}
.exit::before {
transform: rotate(45deg);
}
.exit::after {
transform: rotate(-45deg);
}
<div class="containerInitial ">
<div class="curtainInitial">
<div class="ratio-keeper">
<div class="fence">
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
</div>
<div class="fan">
<svg xmlns="http://www.w3.org/2000/svg" width="70%" height="70%" viewBox="76 130 381 381">
<g id="fan">
<title>Fan</title>
<path fill="#000100" stroke="#000"
d="m166.3352 168.6294c5.5396 2.4448 45.2339 54.394 72.7499 91.0151-9.1901-44.8757-21.7959-109.0279-19.9558-114.796 4.1462-12.9949 33.7039-13.5172 41.5845-13.7579 7.8827-.2415 37.4165-1.5221 42.3488 11.1948 2.1872 5.6436-6.4773 70.4506-12.9142 115.8007 25.2309-38.2323 61.6818-92.5089 67.0612-95.2865 12.119-6.2568 33.3898 14.2749 39.1337 19.6768 5.7424 5.402 27.5341 25.3815 22.0294 37.859-2.4441 5.5389-54.3954 45.2354-91.0172 72.7506 44.8757-9.1901 109.0293-21.7959 114.7974-19.9559 12.9927 4.1442 13.5193 33.7032 13.7586 41.5838.2422 7.8819 1.5221 37.4165-11.192 42.3473-5.6471 2.1894-70.4541-6.4765-115.8049-12.9127 38.2323 25.2323 92.5081 61.6783 95.2871 67.0605 6.2581 12.1175-14.2742 33.3877-19.6776 39.133-5.4027 5.7432-25.3815 27.5341-37.8563 22.0279-5.5396-2.4434-45.2361-54.3961-72.7534-91.0143 9.1901 44.8757 21.7952 109.0287 19.9551 114.7953-4.1434 12.9934-33.7026 13.5157-41.5852 13.7586-7.8799.24-37.4165 1.5221-42.3431-11.1936-2.1887-5.6464 6.4779-70.4541 12.9133-115.8071-25.2323 38.2323-61.6824 92.5124-67.0639 95.2908-12.1169 6.256-33.3891-14.2728-39.1337-19.6754-5.7432-5.4027-27.5313-25.383-22.0251-37.8578 2.4434-5.5396 54.394-45.2339 91.0136-72.7526-44.8764 9.1908-109.0266 21.7944-114.7967 19.9566-12.9934-4.1434-13.5171-33.7025-13.7586-41.5852-.2407-7.8806-1.5221-37.4165 11.1963-42.346 5.6443-2.1879 70.4498 6.4752 115.8 12.9121-38.233-25.2316-92.5081-61.6783-95.2865-67.0612-6.256-12.1169 14.2748-33.3913 19.6768-39.1337 5.4006-5.7438 25.3794-27.5333 37.8584-22.0272z" />
</g>
</svg>
</div>
<div class="cross"></div>
<div class="wrap">
<div class="video video-frame" data-id="CHahce95B1g"></div>
</div>
<div class="video-one"></div>
</div>
<button class="exit" type="button" title="Exit" aria-label="Close"></button>
</div>
</div>
move button outside last div and change bottom on .exit to -257px
html,
body {
height: 100%;
margin: 0;
padding: 0;
}
body {
background: gray;
}
.containerInitial {
position: absolute;
left: 0;
right: 0;
min-height: 100%;
min-width: 255px;
display: flex;
padding: 8px 8px;
}
.curtainInitial {
flex: 1 0 0;
margin: auto;
max-width: 680px;
border: 21px solid;
border-radius: 12px;
border-color: #000 #101010 #000 #101010;
position: relative;
overflow: hidden;
}
.curtainInitial::before {
content: '';
position: absolute;
top: -2px;
left: -2px;
right: -2px;
bottom: -2px;
background: #0a0a0a;
background: radial-gradient(circle, transparent 0% 48.5%, #0a0a0a 48.5%);
border: 1px solid;
border-color: #000 #101010 #000 #101010;
}
.curtainInitial::after {
content: "";
position: absolute;
left: 0;
right: 0;
bottom: 0;
top: 0;
outline: 1px solid green;
pointer-events: none;
}
.fence {
position: absolute;
left: 0;
top: 0;
bottom: 0;
right: 0;
margin: auto;
background:
linear-gradient(45deg,
#0000 7px,
#0a0a0a 0 7.5px,
#0000 0 10px),
linear-gradient(-45deg,
#0000 7px,
#0a0a0a 0 7.5px,
#0000 0 10px),
linear-gradient(to top, #e10019 0%, #957e00 100%);
background-size: 10px 10px,10px 10px, cover;
filter: drop-shadow(0 0 5px #000);
-webkit-animation: fade 5s infinite;
animation: fade 5s infinite;
clip-path: circle(34.5% at center);
}
.fence>div {
position: absolute;
/*top: 0;*/
left: 0;
right: 0;
/*width: 100%;*/
height: 0.55%;
/*height: 2px;*/
background: black;
}
.fence>div:nth-child(1) {
top: 9.8%;
}
.fence>div:nth-child(2) {
top: 19.2%;
}
.fence>div:nth-child(3) {
top: 28.6%;
}
.fence>div:nth-child(4) {
top: 38%;
}
.fence>div:nth-child(5) {
top: 47.4%;
}
.fence>div:nth-child(6) {
top: 56.8%;
}
.fence>div:nth-child(7) {
top: 66.2%;
}
.fence>div:nth-child(8) {
top: 75.6%;
}
.fence>div:nth-child(9) {
top: 85%;
}
.fence>div:nth-child(10) {
top: 94.4%;
}
.fan svg {
position: absolute;
top: 0;
left: 0;
bottom: 0;
right: 0;
width: 100%;
height: 100%;
margin: auto;
}
.cross {
clip-path: circle(34.5% at center);
position: absolute;
left: 0;
top: 0;
bottom: 0;
right: 0;
margin: auto;
width: 100%;
height: 100%;
background: transparent;
}
.cross::before,
.cross::after {
content: "";
position: absolute;
left: 0;
top: 0;
bottom: 0;
right: 0;
margin: auto;
background: black;
}
.cross::before
/*horizontal*/
{
height: 2.8%;
}
.cross::after
/*vertical*/
{
width: 1.4%;
}
.ratio-keeper {
position: relative;
height: 0;
padding-top: 56.25%;
margin: auto;
overflow: hidden;
}
.fan svg {
position: absolute;
top: 0;
left: 0;
bottom: 0;
right: 0;
margin: auto;
width: 100%;
height: 100%;
animation: fan-spin 40s infinite linear;
}
#keyframes fan-spin {
0% {
transform: scale(0.98) rotate(0deg);
}
100% {
transform: scale(0.98) rotate(360deg);
}
}
#-webkit-keyframes fade {
0% {
opacity: 0.9;
}
50% {
opacity: 1;
}
100% {
opacity: 0.9;
}
}
#keyframes fade {
0% {
opacity: 0.9;
}
50% {
opacity: 1;
}
100% {
opacity: 0.9;
}
}
iframe {
display: block;
animation: iframe 5s ease-in 5s forwards;
animation-delay: 1s;
opacity: 0;
}
#keyframes iframe {
to {
opacity: 1;
}
}
.embed-youtube iframe,
.embed-youtube .embed-youtube-play,
.embed-youtube .embed-youtube-play::before {
position: absolute;
}
.embed-youtube iframe {
height: 100%;
width: 100%;
top: 0;
left: 0;
}
.exit {
position: absolute;
top: 200px;
bottom: -275.63px;
margin: auto;
right: 0;
left: 0;
width: 47px;
height: 47px;
cursor: pointer;
border-radius: 100%;
background: transparent;
border: 5px solid red;
box-sizing: border-box;
opacity: 1;
clip-path: circle(50%);
}
.exit::before,
.exit::after {
content: "";
background-color: red;
width: 47px;
height: 5px;
position: absolute;
top: 0px;
left: -5px;
right: 0;
bottom: 0;
margin: auto;
}
.exit::before {
transform: rotate(45deg);
}
.exit::after {
transform: rotate(-45deg);
}
<div class="containerInitial ">
<div class="curtainInitial">
<div class="ratio-keeper">
<div class="fence">
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
</div>
<div class="fan">
<svg xmlns="http://www.w3.org/2000/svg" width="70%" height="70%" viewBox="76 130 381 381">
<g id="fan">
<title>Fan</title>
<path fill="#000100" stroke="#000"
d="m166.3352 168.6294c5.5396 2.4448 45.2339 54.394 72.7499 91.0151-9.1901-44.8757-21.7959-109.0279-19.9558-114.796 4.1462-12.9949 33.7039-13.5172 41.5845-13.7579 7.8827-.2415 37.4165-1.5221 42.3488 11.1948 2.1872 5.6436-6.4773 70.4506-12.9142 115.8007 25.2309-38.2323 61.6818-92.5089 67.0612-95.2865 12.119-6.2568 33.3898 14.2749 39.1337 19.6768 5.7424 5.402 27.5341 25.3815 22.0294 37.859-2.4441 5.5389-54.3954 45.2354-91.0172 72.7506 44.8757-9.1901 109.0293-21.7959 114.7974-19.9559 12.9927 4.1442 13.5193 33.7032 13.7586 41.5838.2422 7.8819 1.5221 37.4165-11.192 42.3473-5.6471 2.1894-70.4541-6.4765-115.8049-12.9127 38.2323 25.2323 92.5081 61.6783 95.2871 67.0605 6.2581 12.1175-14.2742 33.3877-19.6776 39.133-5.4027 5.7432-25.3815 27.5341-37.8563 22.0279-5.5396-2.4434-45.2361-54.3961-72.7534-91.0143 9.1901 44.8757 21.7952 109.0287 19.9551 114.7953-4.1434 12.9934-33.7026 13.5157-41.5852 13.7586-7.8799.24-37.4165 1.5221-42.3431-11.1936-2.1887-5.6464 6.4779-70.4541 12.9133-115.8071-25.2323 38.2323-61.6824 92.5124-67.0639 95.2908-12.1169 6.256-33.3891-14.2728-39.1337-19.6754-5.7432-5.4027-27.5313-25.383-22.0251-37.8578 2.4434-5.5396 54.394-45.2339 91.0136-72.7526-44.8764 9.1908-109.0266 21.7944-114.7967 19.9566-12.9934-4.1434-13.5171-33.7025-13.7586-41.5852-.2407-7.8806-1.5221-37.4165 11.1963-42.346 5.6443-2.1879 70.4498 6.4752 115.8 12.9121-38.233-25.2316-92.5081-61.6783-95.2865-67.0612-6.256-12.1169 14.2748-33.3913 19.6768-39.1337 5.4006-5.7438 25.3794-27.5333 37.8584-22.0272z" />
</g>
</svg>
</div>
<div class="cross"></div>
<div class="wrap">
<div class="video video-frame" data-id="CHahce95B1g"></div>
</div>
<div class="video-one"></div>
</div>
</div>
</div>
<button class="exit" type="button" title="Exit" aria-label="Close"></button>

CSS Skill Bar Animation

I am trying to create a skill bar where the background color of the progress slides in but the label for the Skill bar stays in the same place.
.skill-container * {
box-sizing: border-box;
}
.skill-container {
width: 100%;
border-radius: 5px;
background-color: lightgray;
margin: 20px 0;
overflow: hidden;
}
.skill-container .skill {
display: inline-block;
text-align: left;
color: white;
padding: 10px 0 10px 4px;
border-radius: inherit;
background-color: #312E81;
white-space: nowrap;
position: relative;
animation: animateLeft 1s ease-out;
}
#keyframes animateLeft {
from {
left: -100%
}
to {
left: 0
}
}
.skill-container .skill.skill-level-70 {
width: 70%
}
<div class="skill-container">
<span class="skill skill-level-70">CSS</span>
</div>
So far the animation works well, but the only thing I need to figure out is how to keep the text (CSS) on the left and animate the sliding of the background color to show the progress
Use a pseudo element for the background:
.skill-container .skill {
color: white;
background-color: lightgray;
margin: 5px 0;
padding: 10px 0 10px 4px;
overflow: hidden;
border-radius: 5px;
white-space: nowrap;
position: relative;
z-index:0;
}
.skill-container .skill::before {
content: "";
position: absolute;
background-color: #312E81;
border-radius: inherit;
z-index: -1;
top: 0;
bottom: 0;
left: 0;
animation: animateLeft 1s ease-out;
}
#keyframes animateLeft {
from {
transform: translateX(-100%);
}
}
.skill-container .skill.skill-level-70::before {
width: 70%
}
.skill-container .skill.skill-level-40::before {
width: 40%
}
.skill-container .skill.skill-level-100::before {
width: 100%
}
<div class="skill-container">
<div class="skill skill-level-100">CSS</div>
<div class="skill skill-level-70">HTML</div>
<div class="skill skill-level-40">PHP</div>
</div>
You can optimize with CSS variables:
.skill-container .skill {
color: white;
background-color: lightgray;
margin: 5px 0;
padding: 10px 0 10px 4px;
overflow: hidden;
border-radius: 5px;
white-space: nowrap;
position: relative;
z-index:0;
}
.skill-container .skill::before {
content: "";
position: absolute;
background-color: #312E81;
border-radius: inherit;
z-index: -1;
top: 0;
bottom: 0;
left: 0;
width:var(--l,0%);
animation: animateLeft 1s ease-out;
}
#keyframes animateLeft {
from {
transform: translateX(-100%);
}
}
<div class="skill-container">
<div class="skill" style="--l:100%">CSS</div>
<div class="skill" style="--l:70%">HTML</div>
<div class="skill" style="--l:40%">PHP</div>
</div>

Animating z-index

I have this page and want to apply this to it.
.contact {
width: 0;
height: 0;
border: 50px solid transparent;
border-bottom: 70px solid red;
position: relative;
top: 0;
margin-left: 0;
transform: rotate(90deg);
float: right;
}
.contact:after {
content: '';
position: absolute;
left: -50px;
top: 70px;
width: 0;
height: 0;
border: 50px solid transparent;
border-top: 70px solid red;
}
.contact {
animation: fish 4s linear infinite;
}
#keyframes fish {
0% {
right: 0px;
top: 0px;
}
25% {
right: 200px;
top: 0px;
}
50% {
right: 200px;
top: 200px;
}
75% {
right: 0px;
top: 200px;
}
100% {
right: 0px;
top: 0px;
}
}
.box {height: 50px; width 100px; background-color: black; margin: auto; transform: rotate(90deg);}
<div class="contact"></div>
<div class="box"></div>
The problem is that various other elements on the page have different z-index and I want to send it behind some and in front of others. Can I animate the z-index, as it were? For example 5s into animation z-index 1 would apply, 10s in z-index 3 would apply.
Yes. It's done exactly as you'd expect. Just add z-index into your animation keyframes like so:
.contact {
width: 0;
height: 0;
border: 50px solid transparent;
border-bottom: 70px solid red;
position: relative;
top: 0;
margin-left: 0;
transform: rotate(90deg);
float: right;
}
.contact:after {
content: '';
position: absolute;
left: -50px;
top: 70px;
width: 0;
height: 0;
border: 50px solid transparent;
border-top: 70px solid red;
}
.contact {
animation: fish 4s linear infinite;
}
#keyframes fish {
0% {
right: 0px;
top: 0px;
}
25% {
right: 200px;
top: 0px;
}
50% {
right: 200px;
top: 200px;
z-index:100;
}
75% {
right: 0px;
top: 200px;
}
100% {
right: 0px;
top: 0px;
}
}
.box {height: 50px; width 100px; background-color: black; margin: auto; transform: rotate(90deg);}
<div class="contact"></div>
<div class="box"></div>

I need to reduce the gap between the headings when resizing the browser

This the code i have used but, when i resize the browser, the space between the two headings for the tab view is not working. I should get the texts without the space when i resize the browser.Below is the html and css code i have used to make it happen but, its not working,could you please help me through this.
Here is the my code:
body {
width: 100%;
overflow-x: hidden;
overflow-y: auto;
padding: 0;
display:block;
padding-top: 100px;
background-size:100%;
margin: 0;
}
#header{
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100px;
background: #FFF;
border-bottom: 2px solid #000;
}
#carscene{
width: 100%;
height: 113vh;
background: url('app-car-scene-min.png') no-repeat;
background-size: contain;
color: #FFF;
font-family :"Source Sans Pro", Arial, Helvetica, sans-serif;
position: relative;
background-position: top -175px left -2px;
background-size: 108% 151%;
}
#carscene #title-holder{
position: absolute;
top: 30vh;
left: 8vw;
overflow: hidden;
padding-bottom: 50px;
height: 6vw;
width: 70vw;
}
#carscene #title-holder h1{
position: absolute;
font-size: 5vw;
font-weight: bold;
animation: emerge-up 2s ease-out;
margin: 0;
padding: 0;
top: 6%;
animation-duration: 2.5s;
}
#-webkit-keyframes emerge-up {
0% {
top: 250%;
}
10% {
top: 250%;
}
65% {
top: -15%;
}
100% {
top: 5%;
}
}
#keyframes emerge-up {
0% {
top: 250%;
}
10% {
top: 250%;
}
65% {
top: -15%;
}
100% {
top: 5%;
}
}
#everymin {
width: 100%;
height: 25vh;
background: #abc;
}
#carscene h2 {
position: absolute;
font-size: 2vw;
font-weight: bold;
margin: 0;
padding-left: 13.5vw;
top: 48vh;
left:-8vh;
opacity: 0;
animation-delay: 1.5s;
transform: scale(0);
animation-fill-mode: forwards;
}
.scale-in {
transform: scale(1);
animation-name: scaleIn;
animation-iteration-count: 1;
animation-timing-function: ease;
animation-duration: 1.5s;
}
#-webkit-keyframes scaleIn {
0% {
opacity: 0;
transform: scale(0.8);
}
50% {
opacity: 1;
}
100% {
opacity: 1;
transform: scale(1);
}
}
#keyframes scaleIn {
0% {
opacity: 0;
transform: scale(0.8);
}
50% {
opacity: 1;
}
100% {
opacity: 1;
transform: scale(1);
}
}
#carscene #title-button {
position: absolute;
bottom: 52vh;
left: 9.5vw;
overflow: hidden;
height: 11vh;
width: 50vw;
animation-duration: 3.5s;
top:57vh;
}
#carscene h3 {
position: absolute;
width: 18vw;
font-size: 2.5vh;
background: #35baf2;
height: 6vh;
margin: -1px;
padding-top: 20px;
left: 0vh;
bottom: 100px;
border-radius: 9px;
text-align: center;
animation: emerge-down 1.5s ease forwards;
animation-delay: 2.2s;
}
#-webkit-keyframes emerge-down {
0% {
bottom: 100px;
}
100% {
bottom: 15px;
}
}
#keyframes emerge-down {
0% {
bottom: 100px;
}
100% {
bottom: 15px;
}
}
#carscene #title-check {
position: absolute;
top: 67vh;
left: -8vw;
overflow: hidden;
height: 20vh;
width: 50vw;
}
#carscene ul{
position: absolute;
font-size: 1.6vw;
margin: 0;
padding-left: 13.5vw;
top: -8%;
list-style: none;
white-space:pre;
animation-duration: 6s;
transition: transform .4s ease-in-out, opacity .4s ease-in-out;
}
.fa-check-square-o:before {
content: "\f046";
font-size: 90%;
color: rgb(0,206,89);
}
.fade-in {
animation-name: fadeInOpacity;
animation-iteration-count: 1;
animation-timing-function: ease-in;
animation-delay: 3s;
opacity: 0;
animation-fill-mode: forwards;
animation-duration: 1.5s;
}
#keyframes fadeInOpacity {
0% {
opacity: 0;
}
100% {
opacity: 1;
}
}
#media only screen and (min-device-width:320px) and (max-width: 480px) {
#carscene{
background: url('app-car-scene-min.png') no-repeat;
background-position: right 20% bottom -251px;
background-size:333% 140%;
width:100%;
height:116%;
}
#carscene #title-holder {
height: 13vw;
width: 80vw;
top: 10vh;
left: 11vw;
max-height:100%;
}
#carscene #title-holder h1 {
font-size: 8.5vw;
}
#carscene h2 {
font-size: 4vw;
padding-left: 10.5vw;
top: 19vh;
left:0vh;
}
#carscene #title-button {
left: 23vw;
height: 9vh;
top: 26vh;
border-radius:6px;
}
#carscene h3 {
width: 52vw;
font-size: 2.5vh;
height: 6vh;
border-radius:3px;
min-height:100%;
}
#carscene #title-check {
top: 35vh;
left: 0vw;
width: 100%;
}
#carscene ul {
font-size: 4.2vw;
white-space:inherit;
padding: 0;
width: 100%;
left:7vh;
top:2%;
}
li {
float: left;
padding-left: 5%;
}
#everymin {
width: 100%;
height: 25vh;
background: #abc;
}
}
#media (min-device-width: 480px) and (max-device-width: 778px) {
#carscene{
background: url('app-car-scene-min.png') no-repeat;
background-position:right -125px bottom 399px;
background-size: 150% 80%;
width:105%;
height:127%;
position:relative;
}
#carscene #title-holder {
top: 3vh;
left: 8vw;
height: 33vw;
width: 30vw;
position:absolute;
}
#carscene #title-holder h1 {
font-size: 8vw;
top:6%;
}
#carscene h2 {
padding-left: 6.5vw;
font-size: 3vw;
top: 31vh;
left:0vh;
width:100%;
}
#carscene #title-text {
position: absolute;
width: 50vw;
top: -4vh;
}
#carscene #title-button {
height: 11vh;
width: 50vw;
max-height:100%;
top: 34vh;
left: 5vw;
position:absolute;
}
#carscene h3 {
width: 43vw;
overflow:auto;
margin:2px;
padding-top:24px;
font-size:2.5vh;
}
#carscene ul {
font-size: 27px;
padding-left:0.5vw;
overflow:auto;
position:absolute;
}
#carscene #title-check {
top: 43vh;
left: -6vw;
}
}
#media (min-width: 779px) and (max-width: 1024px){
#carscene {
background: url('app-car-scene-min.png') no-repeat;
background-size: contain;
width:107%;
height:122%;
}
#carscene #title-holder h1 {
font-size: 5.3vw;
}
#carscene #title-holder {
top: 15vh;
left: 8vw;
}
#carscene h2 {
top: 23vh;
left: -5vw;
font-size:2.3vw;
}
#carscene h3 {
width: 38vw;
}
#carscene #title-button {
left: 9vw;
top: 25vh;
width:36vw;
text-align:center;
}
#carscene #title-check {
top: 29vh;
left: -11vw;
}
#carscene ul {
font-size: 2.7vw;
top:25%;
}
}
<head>
<title>Lucep Banner work</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="https://fonts.googleapis.com/css?family=Source+Sans+Pro" rel="stylesheet">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css">
<link rel='stylesheet' href='banner.css' type='text/css' media='all' />
</head>
<body>
<div id="header">Lucep logo header</div>
<div id="carscene">
<div id="title-holder">
<h1>Capture. Call. Convert.</h1>
</div>
<div id="title-text">
<h2 class="scale-in">Call back customers faster than your competition</h2>
</div>
<div id="title-button">
<h3>Start Your Free Trial ►</h3>
</div>
<div id="title-check" class="fade-in">
<ul>
<i class="fa fa-check-square-o fa_custom"> No credit card required</i>
<i class="fa fa-check-square-o fa_custom"> 30 day free trial</i>
</ul>
</div>
</div>
<div id="everymin">
<h1>Every minute matters</h1>
bla bla bla
</div>
</body>
The problem in the code was it doesn't have equalized height formatting for each div in the body section.Adjust them in relative way to get your web page.

Can't manage to center the loader

I'm using a loader in my application, but I can't manage to properly centre it.
As you are going to see it's slightly moved to left side of the screen.
Here's the fiddle: Loader
Here's the HTML code:
<div class="loader">
<div class="loader__hexagon loader__hexagon--value"></div>
<div class="loader__hexagon loader__hexagon--value"></div>
<div class="loader__hexagon loader__hexagon--value"></div>
</div>
Here's the SCSS code:
.loader-graph-default{
background-color: black;
display: none;
}
.loader-graph-loading{
display: inline;
position: absolute;
z-index: 100;
height: 100%;
width: 100%;
}
.loader {
background: none;
position: relative;
width: 60px;
height: 60px;
margin: auto;
text-align: center;
&__hexagon {
position: absolute;
width: 12px;
height: 20px;
margin: 5px;
transform: rotate(30deg);
animation: fade 1s infinite;
animation-delay: 0s;
background: white;
&--value {
background: #009ECB;
}
&:first-of-type {
top: 20px;
left: -12px;
animation-delay: .4s;
}
&:last-of-type {
top: 20px;
left: 12px;
animation-delay: .2s;
}
&:before {
content: " ";
position: absolute;
left: 0;
top: 0;
width: 12px;
height:20px;
background: inherit;
transform: rotate(-62deg);
}
&:after {
content: " ";
position: absolute;
left: 0;
top: 0;
width: 12px;
height: 20px;
background: inherit;
transform: rotate(62deg);
}
}
}
#keyframes fade{
0%{
opacity: 1;
}
50%{
opacity: .1;
}
100%{
opacity: 1;
}
}
If you go to the fiddle and you inspect the div with the class "loader" you can see that it's not centred.
What am I missing?
when you rotate a div, of course it changes it centre point, so i just repositioned it.
.loader-graph-default{
background-color: black;
display: none;
}
.loader-graph-loading{
display: inline;
position: absolute;
z-index: 100;
height: 100%;
width: 100%;
}
.loader {
background: none;
position: relative;
width: 60px;
height: 60px;
margin: auto;
text-align: center;
&__hexagon {
position: absolute;
width: 12px;
height: 20px;
margin: 5px;
transform: rotate(30deg);
animation: fade 1s infinite;
animation-delay: 0s;
/*background: $uiColor;*/
background: white;
/*
&--carbon {
background: $carbon;
}
&--value {
background: $value;
}
&--research {
background: $research;
}
&--quality {
background: $quality;
}
*/
&--value {
background: #009ECB;
}
&:first-of-type {
top: 20px;
right: 50%;
margin-left: 3px;
animation-delay: 0.4s;
}
&:last-of-type {
top: 20px;
left: 50%;
animation-delay: 0.2s;
margin-left: 6px;
}
&:nth-child(2) {
left: 50%;
margin-left: -6px;
}
&:before {
content: " ";
position: absolute;
left: 0;
top: 0;
width: 12px;
height:20px;
background: inherit;
transform: rotate(-62deg);
}
&:after {
content: " ";
position: absolute;
left: 0;
top: 0;
width: 12px;
height: 20px;
background: inherit;
transform: rotate(62deg);
}
}
}
#keyframes fade{
0%{
opacity: 1;
}
50%{
opacity: .1;
}
100%{
opacity: 1;
}
}
<div class="loader">
<div class="loader__hexagon loader__hexagon--value"></div>
<div class="loader__hexagon loader__hexagon--value"></div>
<div class="loader__hexagon loader__hexagon--value"></div>
</div>
Fiddle
You can set loader width 60px to 48px to resolve this. check updated snippet below..
.loader-graph-default {
background-color: black;
display: none;
}
.loader-graph-loading {
display: inline;
position: absolute;
z-index: 100;
height: 100%;
width: 100%;
}
.loader {
background: none;
position: relative;
width: 48px;
height: 60px;
margin: auto;
text-align: center;
left: 12px;
}
.loader__hexagon {
position: absolute;
width: 12px;
height: 20px;
margin: 5px;
transform: rotate(30deg);
animation: fade 1s infinite;
animation-delay: 0s;
background: white;
}
.loader__hexagon--value {
background: #009ECB;
}
.loader__hexagon:first-of-type {
top: 20px;
left: -12px;
animation-delay: 0.4s;
}
.loader__hexagon:last-of-type {
top: 20px;
left: 12px;
animation-delay: 0.2s;
}
.loader__hexagon:before {
content: " ";
position: absolute;
left: 0;
top: 0;
width: 12px;
height: 20px;
background: inherit;
transform: rotate(-62deg);
}
.loader__hexagon:after {
content: " ";
position: absolute;
left: 0;
top: 0;
width: 12px;
height: 20px;
background: inherit;
transform: rotate(62deg);
}
#keyframes fade {
0% {
opacity: 1;
}
50% {
opacity: 0.1;
}
100% {
opacity: 1;
}
}
<div class="loader">
<div class="loader__hexagon loader__hexagon--value"></div>
<div class="loader__hexagon loader__hexagon--value"></div>
<div class="loader__hexagon loader__hexagon--value"></div>
</div>
You have added left:-12px to the first of div with class "loader__hexagon loader__hexagon--value", which shifts the whole block to the left by -12px.
Also the width of the Loader is not 60px.
The style should be as given below :
.loader__hexagon:first-of-type {
top: 20px;
animation-delay: 0.4s;}
Add a style for second child:
.loader__hexagon:nth-child(2) {
left: 12px; }
Edit style of third child:
.loader__hexagon:last-of-type {
top: 20px;
left: 23px;
animation-delay: 0.2s; }
Reduce the width of the loader to 45px:
.loader {
background: none;
position: relative;
width: 45px;
height: 60px;
margin: auto;
text-align: center; }
You are using absolute positioning on your hexagons, that's why they are not centered, try a different approach such as display: inline-block with adjusted margins (some space inbetween) for bottom hexagons.
&__hexagon {
margin: 0 auto;
}
&:first-of-type {
display: block;
}
&:nth-child(2) {
margin-right: 4px;
display: inline-block;
}
&:last-of-type {
margin-left: 4px;
display: inline-block;
}
fiddle