This question already has answers here:
Using percentage values with background-position on a linear-gradient
(2 answers)
Closed 4 years ago.
Can't animate my Gradient Fill.
Here's my CSS and HTML:..
.health {
height: 412px;
padding-top: 162px;
background: linear-gradient(270deg, #ff0000, #cdff00);;
animation-name: gradian;
animation-duration: 4s;
animation-iteration-count: infinite;
}
#-webkit-keyframes gradian {
0%{background-position:0% 50%}
50%{background-position:100% 50%}
100%{background-position:0% 50%}
}
#-moz-keyframes gradian {
0%{background-position:0% 50%}
50%{background-position:100% 50%}
100%{background-position:0% 50%}
}
#keyframes gradian {
0%{background-position:0% 50%}
50%{background-position:100% 50%}
100%{background-position:0% 50%}
}
<section class="health" class="section-bg">
<div class="container">
<div class="row portfolio-container" title ="Click here to order Diabetes diseases" style="">
<a href="#"><div class="col-lg-12 col-md-12 portfolio-item filter-app wow fadeInRight" data-wow-delay="0.2s" style="position: absolute;visibility: visible;animation-delay: 0.2s;animation-name: fadeInRight;overflow: visible;">
<div class="portfolio-wrap">
<div id="" class ="col-lg-12 col-md-12">
<center>
<p style="font-size: 42px;color: aliceblue;font-weight: bold;">Health Boosters</p>
</center>
</div>
</div>
</div>
</a>
<div class ="col-lg-12 col-md-12" style="height: 47px;animation-name:colorjoin;animation-duration:1s;">
</div></div></div>
</section>
Why the animation does not work?
Where as it should move round and round infinitely!
Firefox shows in Inspect Element that the animation is working, then too I can't see the animation!
I have tried the method(percentage method) that has to be used, but it didn't work!
I had added background-size: 400% 400%; in health, class your not use that.
.health {
width: 100wh;
height: 90vh;
color: #fff;
background: linear-gradient(-45deg, #EE7752, #E73C7E, #23A6D5, #23D5AB);
background-size: 400% 400%;
-webkit-animation: gradian 15s ease infinite;
-moz-animation: gradian 15s ease infinite;
animation: gradian 15s ease infinite;
}
#-webkit-keyframes gradian {
0% {
background-position: 0% 50%
}
50% {
background-position: 100% 50%
}
100% {
background-position: 0% 50%
}
}
#-moz-keyframes gradian {
0% {
background-position: 0% 50%
}
50% {
background-position: 100% 50%
}
100% {
background-position: 0% 50%
}
}
#keyframes gradian {
0% {
background-position: 0% 50%
}
50% {
background-position: 100% 50%
}
100% {
background-position: 0% 50%
}
}
<section class="health" class="section-bg">
<div class="container">
<div class="row portfolio-container" title ="Click here to order Diabetes diseases" style="">
<a href="#"><div class="col-lg-12 col-md-12 portfolio-item filter-app wow fadeInRight" data-wow-delay="0.2s" style="position: absolute;visibility: visible;animation-delay: 0.2s;animation-name: fadeInRight;overflow: visible;">
<div class="portfolio-wrap">
<div id="" class ="col-lg-12 col-md-12">
<center>
<p style="font-size: 42px;color: aliceblue;font-weight: bold;">Health Boosters</p>
</center>
</div>
</div>
</div>
</a>
<div class ="col-lg-12 col-md-12" style="height: 47px;animation-name:colorjoin;animation-duration:1s;">
</div></div></div>
</section>
Related
I have the below code to perform a cross fade between multiple items. Each xfader_ is then applied as a class to the relevant item in a list.
This code works well except when the page is first loaded and all items begin on top of the other. After a few seconds the fading works correctly.
How can I set it so only one item is displayed to begin with?
#keyframes xfade { 0% { opacity: 1; } 31.25% { opacity: 1; } 33.33333% { opacity: 0; } 97.91666% { opacity: 0; } 100% { opacity: 1; } }
.xfader_0 { animation: xfade 48s linear 0s infinite; opacity: 1; }
.xfader_1 { animation: xfade 48s linear 16s infinite; }
.xfader_2 { animation: xfade 48s linear 32s infinite; }
The animation is assigned as below:
<div id='p1r0rmks2Otr' class='cell rmks' style='top:0px;position:absolute;'>
<div id='p1r0rmks2' class='cell rmks p1r0rmks2animLeft'>
<div id='p1r0rmks2Inr' class='cell rmks xfader_2'>
ૈપોૂગેુદગલુદલૈગૂપૂપગેૂીોલેતોબૂપગેગેોૂાોેૂદિ્ગિલાા્</div>
</div>
</div>
<div id='p1r0rmks1Otr' class='cell rmks' style='top:0px;position:absolute;'>
<div id='p1r0rmks1' class='cell rmks p1r0rmks1animLeft'>
<div id='p1r0rmks1Inr' class='cell rmks xfader_1'>
Flight 5678 has been cancelled</div>
</div>
</div>
<div id='p1r0rmks0Otr' class='cell rmks' style='top:0px;position:absolute;'>
<div id='p1r0rmks0' class='cell rmks p1r0rmks0animLeft'>
<div id='p1r0rmks0Inr' class='cell rmks xfader_0'>
Departure Gate 1234 Out of Service</div>
</div>
</div>
</div>
#keyframes xfade { 0% { opacity: 1; } 31.25% { opacity: 1; } 33.33333% { opacity: 0; } 97.91666% { opacity: 0; } 100% { opacity: 1; } }
.xfader_0 { animation: xfade 48s linear 0s infinite; opacity: 1; }
.xfader_1 { animation: xfade 48s linear 16s infinite; }
.xfader_2 { animation: xfade 48s linear 32s infinite; }
<div id='p1r0rmks2Otr' class='cell rmks' style='top:0px;position:absolute;'>
<div id='p1r0rmks2' class='cell rmks p1r0rmks2animLeft'>
<div id='p1r0rmks2Inr' class='cell rmks xfader_2'>
ૈપોૂગેુદગલુદલૈગૂપૂપગેૂીોલેતોબૂપગેગેોૂાોેૂદિ્ગિલાા્</div>
</div>
</div>
<div id='p1r0rmks1Otr' class='cell rmks' style='top:0px;position:absolute;'>
<div id='p1r0rmks1' class='cell rmks p1r0rmks1animLeft'>
<div id='p1r0rmks1Inr' class='cell rmks xfader_1'>
Flight 5678 has been cancelled</div>
</div>
</div>
<div id='p1r0rmks0Otr' class='cell rmks' style='top:0px;position:absolute;'>
<div id='p1r0rmks0' class='cell rmks p1r0rmks0animLeft'>
<div id='p1r0rmks0Inr' class='cell rmks xfader_0'>
Departure Gate 1234 Out of Service</div>
</div>
</div>
</div>
If I understand your requirement correctly, you just need to add initial 'opacity: 0' to all xfader_ elements, may be using a common selector. Here I've tried to implement something similar. I added some additional CSS rules for demo, but the important property here is the opacity: 0 for the div selector.
#keyframes xfade { 0% { opacity: 1; } 31.25% { opacity: 1; } 33.33333% { opacity: 0; } 97.91666% { opacity: 0; } 100% { opacity: 1; } }
.xfader_0 { animation: xfade 12s linear 0s infinite; opacity: 1; }
.xfader_1 { animation: xfade 12s linear 4s infinite; }
.xfader_2 { animation: xfade 12s linear 8s infinite; }
/*Extra CSS for this demo*/
div {
opacity: 0;
position: absolute;
top: 0;
background-color: #aeaeae;
padding: 10px;
}
<div id="div_0" class="xfader_0">First message</div>
<div id="div_1" class="xfader_1">Second message</div>
<div id="div_2" class="xfader_2">Third message</div>
I am trying to figure out how I can write a CSS animation that allows an image (id: slam) to suddenly appear on screen and cover all of the content without displacing any of the text. So far, this is what I have:
HTML:
body{
height: 100%;
}
div{
overflow: auto;
text-align: center;
}
#-webkit-keyframes slam-animation {
0% {
opacity: 0;
-webkit-transform: scale(10);
}
100% {
opacity: 1;
-webkit-transform: rotate(-30deg) scale(1);
}
}
#slam {
-webkit-animation-name: slam-animation;
-webkit-animation-duration: 1s;
-webkit-animation-direction: normal;
-webkit-animation-timing-function: linear;
-webkit-animation-fill-mode: forwards;
}
<body>
<img id="slam" src="assets/images/Undesirable.jpg" alt = "undesirable">
<header>
<h1>Text</h1>
</header>
<div class="main_game">
<p>Stuff</p>
<div class = "col-xs-2">
</div>
<div class = "left_box col-xs-4">
<p>Stuff</p>
</div>
<div class = "right_box col-xs-4">
<p>Stuff</p>
</div>
<div class = "col-xs-2">
</div>
</div>
</body>
Use position:absolute to your image.
Using absolute position the element is removed from the normal document flow; no space is created for the element in the page layout i.e. it will not affect the position of other elements.
Reference Link to understand position absolute
Stack Snippet
body {
height: 100%;
}
.main_game div {
text-align: center;
}
.main {
position: relative;
}
#-webkit-keyframes slam-animation {
0% {
opacity: 0;
-webkit-transform: scale(10);
}
100% {
opacity: 1;
-webkit-transform: rotate(-30deg) scale(1);
}
}
img#slam {
position: absolute;
top: 0;
left: 0;
}
#slam {
-webkit-animation-name: slam-animation;
-webkit-animation-duration: 1s;
-webkit-animation-direction: normal;
-webkit-animation-timing-function: linear;
-webkit-animation-fill-mode: forwards;
}
<div class="main">
<img id="slam" src="http://via.placeholder.com/350x350" alt="undesirable">
<header>
<h1>Text</h1>
</header>
<div class="main_game">
<p>Stuff</p>
<div class="col-xs-2">
</div>
<div class="left_box col-xs-4">
<p>Stuff</p>
</div>
<div class="right_box col-xs-4">
<p>Stuff</p>
</div>
<div class="col-xs-2">
</div>
</div>
</div>
From the first answer for this question.
I have a div that need to have an absolute position but the problem is that I have a responsive website and I want this div to be automatically placed in a row.
Some code:
<div class="row">
<h2 class="page-header" > animation:</h2>
</div>
<div class="row"> <!--THIS SHOULD BE JUST AFTER THE PREVIOUS DIV -->
<div class="fadein"> <!-- THIS DIV HAVE AN OBSOLUTE POSITION -->
<img id="f3" src="http://i.imgur.com/R7A9JXc.png">
<img id="f2" src="http://i.imgur.com/D5yaJeW.png">
<img id="f1" src="http://i.imgur.com/EUqZ1Er.png">
</div>
</div>
Any suggestion ?
Issue Explaination:
If your looking for positioning to your elements. Simply you need to add position: relative; your row class and need to adjust the margin also.
More Information: CSS Positions
I'm providing you demo can check it once.
DEMO CODE:
h1,h2,h3,h4,h5,h6 {
text-align: center;
margin: 0;
padding: 0;
}
.row {
position: relative;
margin-bottom: 20px;
}
.fadein {
position:absolute;
top:0px;
left:50%;
margin:auto;
}
.fadein img {
position:absolute;
left:-65px;
top:0;
-webkit-animation-name: fade;
-webkit-animation-iteration-count: infinite;
-webkit-animation-duration: 6s;
animation-name: fade;
animation-iteration-count: infinite;
animation-duration: 6s;
}
#-webkit-keyframes fade {
0% {opacity: 0;}
20% {opacity: 1;}
33% {opacity: 1;}
53% {opacity: 0;}
100% {opacity: 0;}
}
#keyframes fade {
0% {opacity: 0;}
20% {opacity: 1;}
33% {opacity: 1;}
53% {opacity: 0;}
100% {opacity: 0;}
}
#f1 {
background-color: lightblue;
}
#f2 {
-webkit-animation-delay: -4s;
background-color: yellow;
}
#f3 {
-webkit-animation-delay: -2s;
background-color: lightgreen;
}
<div class="row">
<h2 class="page-header" > animation:
</h2>
</div>
<div class="row">
<!--THIS SHOULD BE JUST AFTER THE PREVIOUS DIV -->
<div class="fadein">
<!-- THIS DIV HAVE AN OBSOLUTE POSITION -->
<img id="f3" src="http://i.imgur.com/R7A9JXc.png">
<img id="f2" src="http://i.imgur.com/D5yaJeW.png">
<img id="f1" src="http://i.imgur.com/EUqZ1Er.png">
</div>
</div>
<div class="row">
<!--THIS SHOULD BE JUST AFTER THE PREVIOUS DIV -->
<div class="fadein">
<!-- THIS DIV HAVE AN OBSOLUTE POSITION -->
<img id="f3" src="http://i.imgur.com/R7A9JXc.png">
<img id="f2" src="http://i.imgur.com/D5yaJeW.png">
<img id="f1" src="http://i.imgur.com/EUqZ1Er.png">
</div>
</div>
I have created a div that uses a linear gradient. When I zoom out (and or zoom in) my gradient shrinks and grows depending on how much I zoom out or in, I set a specific width to try to stop this. It didn't work.
body{
background: linear-gradient(200deg,#aebcbf -10%,#6e7774 110%,#0a0809 1000%);
background-repeat:no-repeat
}
img {
animation-name: rotate;
animation-iteration-count: infinite;
animation-duration:1s;
animation-direction: reverse;
animation-timing-function: ease-in;
animation-play-state: playing;
float: left;
opacity:0.5;
border-radius:90%;
}
h1{
font-size:20px;
font-family: monospace;
font-variant-caps:titling-caps;
text-align:center;
text-decoration-style: wavy;
text-shadow: 2px 2px #FFFFFF;
}
#keyframes rotate {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
}
#css-gradient {
background: linear-gradient(blue, white);
width:47%;
border-style:outset;
background-repeat:no-repeat
}
<div id="css-gradient">
<img src="http://i.imgur.com/gQioYac.png" draggable="false">
<img src="http://i.imgur.com/gQioYac.png" draggable="false">
<img src="http://i.imgur.com/gQioYac.png" draggable="false">
<img src="http://i.imgur.com/gQioYac.png" draggable="false">
<img src="http://i.imgur.com/gQioYac.png" draggable="false">
<div style="clear: left;"></div>
<input type=color style="width:15px;height:100px;position:absolute;left:635px;top:8px;height:125px">
<h1 title="If successful this will be in a white box">Hover over me!</h1>
<hr style="width:300px;position:relative;top:-5px;border-style:double">
</div>
Here's a JSFiddle (https://jsfiddle.net/ffksjqp2/1/)
Im not sur I understood your problem. Do you mean a zoom in / zoom out with your browser ?
Anyway you can try this with your css-gradient class :
#css-gradient {
background: linear-gradient(blue, white);
background-attachment: fixed;
width:47%;
border-style:outset;
background-repeat:no-repeat
}
I am working on pure CSS carousel that changes 4 divs with pictures and hyperlinks by dissolving them over blue background.
It works fine in IE10/11, Opera 15, Mozila 23, Safari 5.1.7 (win), Safari ? (osx108).
When running in Chrome 29 it is almost ok except one issue. If it is opened in 2+ browser tabs it looses synchronisation and skips images almost immediately. If it is opened in 2+ browser windows everything is ok.
It is getting broken in the same way in Safari on iPad2.
Is it a browser or code problem?
HTML:
<!DOCTYPE html>
<html lang="en">
<head>
<title>Carousel v0</title>
<link href="carousel.css" rel="stylesheet" type="text/css">
</head>
<body>
<!-- Carousel Start -->
<div class="carousel-items">
<div id="carousel-item-1" class="carousel-item">
<a class="carousel-item-text" href="#" title="Go to Showcase Item 1">
<span class="carousel-item-title">Showcase Item 1 Title</span>
<span class="carousel-item-description">Brief description or introduction into Showcase Item 1.</span>
</a>
</div>
<div id="carousel-item-2" class="carousel-item">
<a class="carousel-item-text" href="#" title="Go to Showcase Item 2">
<span class="carousel-item-title">Showcase Item 2 Title</span>
<span class="carousel-item-description">Brief description or introduction into Showcase Item 2.</span>
</a>
</div>
<div id="carousel-item-3" class="carousel-item">
<a class="carousel-item-text" href="#" title="Go to Showcase Item 3">
<span class="carousel-item-title">Showcase Item 3 Title</span>
<span class="carousel-item-description">Brief description or introduction into Showcase Item 3.</span>
</a>
</div>
<div id="carousel-item-4" class="carousel-item">
<a class="carousel-item-text" href="#" title="Go to Showcase Item 4">
<span class="carousel-item-title">Showcase Item 4 Title</span>
<span class="carousel-item-description">Brief description or introduction into Showcase Item 4.</span>
</a>
</div>
</div>
<!-- Carousel Finish -->
</body>
</html>
CSS:
/* Container to position carousel composition */
.carousel-items {
overflow: hidden;
width: 923px;
height: 355px;
background: rgba(0,19,127,0.3);
}
/* Deafault position of carousel items */
.carousel-item {
position: absolute!important;
width: 923px;
height:355px;
opacity: 0;
-webkit-animation: colorDissolve 24s linear infinite;
-moz-animation: colorDissolve 24s linear infinite;
-ms-animation: colorDissolve 24s linear infinite;
animation: colorDissolve 24s linear infinite;
}
/* Backgrounds to carousel items */
#carousel-item-1{background-image:url('one.jpg');}
#carousel-item-2{background-image:url('two.jpg');}
#carousel-item-3{background-image:url('three.jpg');}
#carousel-item-4{background-image:url('four.jpg');}
/* Animation delay for carousel item 2 */
.carousel-item:nth-child(2) {
-webkit-animation-delay: 6s;
-moz-animation-delay: 6s;
-ms-animation-delay: 6s;
animation-delay: 6s;
}
/* Animation delay for carousel item 3 */
.carousel-item:nth-child(3) {
-webkit-animation-delay: 12s;
-moz-animation-delay: 12s;
-ms-animation-delay: 12s;
animation-delay: 12s;
}
/* Animation delay for carousel item 4 */
.carousel-item:nth-child(4) {
-webkit-animation-delay: 18s;
-moz-animation-delay: 18s;
-ms-animation-delay: 18s;
animation-delay: 18s;
}
/* Appearance of carousel item description - Initial style*/
.carousel-item-text {
position:relative;
display:block;
top:285px;
z-index: 1500;
width: 923px;
height: 70px;
overflow: hidden;
color:#ffffff;
text-decoration:none;
background: rgba(0,19,127,0.3);
-webkit-transition: all 750ms ease;
-moz-transition: all 750ms ease;
-o-transition: all 750ms ease;
-ms-transition: all 750ms ease;
transition: all 750ms ease;
}
/* Appearance of carousel item description - Item hover style */
.carousel-item:hover > .carousel-item-text {
top:205px;
height: 150px;
}
/* Title of carousel item */
.carousel-item-title {
position:relative;
padding-left:20px;
font-size:xx-large;
line-height:70px;
letter-spacing: 2px;
}
/* Description of carousel item */
.carousel-item-description {
position:relative;
display:block;
width:783px;
padding-left:20px;
line-height:130%;
font-size:x-large;
}
/* The keyframes calculations are based on assumption of 4 items in the carousel. */
#-webkit-keyframes colorDissolve {
0%, 27%, 100% { opacity: 0; }
2%, 25% { opacity: 1; z-index:1000;}
}
#-moz-keyframes colorDissolve {
0%, 27%, 100% { opacity: 0; }
2%, 25% { opacity: 1; z-index:1000;}
}
#-ms-keyframes colorDissolve {
0%, 27%, 100% { opacity: 0; }
2%, 25% { opacity: 1; z-index:1000;}
}
#keyframes colorDissolve {
0%, 27%, 100% { opacity: 0; }
2%, 25% { opacity: 1; z-index:1000;}
}