I have the following HTML:
<div class="rating">
<div class="star active"></div>
<div class="star active"></div>
<div class="star active"></div>
<div class="star"></div>
<div class="star"></div>
</div>
Output:
★★★☆☆
How do I animate in CSS the active stars, one by one?
I tried:
.star {
transition: background-color 0.5s ease;
background-color: #eee;
}
.star.active {
background-color: #000;
}
This transitions the color of all the active stars at once. How to I transition the active stars one by one, from left to right?
I am trying to achieve this without JS. The rating score can be anything. Also the range can be any number (there could be 3 or 5 or 8 or 10 stars, etc)
Because of the active class is already assigned, it's better to use animation instead of transition.
.star {
background-color: #eee;
}
.star.active {
animation: star-pop 0.5s ease forwards;
}
#keyframes star-pop {
to {
background-color: #000;
}
}
Then you can give a different animation-delay for different nth-child:
.star.active:nth-child(1) {
animation-delay: 0s;
}
.star.active:nth-child(2) {
animation-delay: 0.5s;
}
.star.active:nth-child(3) {
animation-delay: 1s;
}
.star.active:nth-child(4) {
animation-delay: 1.5s;
}
.star.active:nth-child(5) {
animation-delay: 2s;
}
/* ... */
If you have a css precompiler(such as sass), you can achieve it with a loop:
.star.active {
// change the number 5 to maximum possible stars(8, 10, etc.)
#for $i from 1 through 5 {
&:nth-child(#{$i}) {
animation-delay: #{($i - 1) * 0.5}s;
}
}
}
.star {
display: inline-block;
width: 40px;
height: 40px;
border: solid 1px #000;
background-color: #eee;
}
.star.active {
animation: star-pop 0.5s ease forwards;
}
.star.active:nth-child(1) {
animation-delay: 0s;
}
.star.active:nth-child(2) {
animation-delay: 0.5s;
}
.star.active:nth-child(3) {
animation-delay: 1s;
}
.star.active:nth-child(4) {
animation-delay: 1.5s;
}
.star.active:nth-child(5) {
animation-delay: 2s;
}
#keyframes star-pop {
to {
background-color: #000;
}
}
<div class="rating">
<div class="star active"></div>
<div class="star active"></div>
<div class="star active"></div>
<div class="star"></div>
<div class="star"></div>
</div>
Related
I want to add to this slider another slide:
codepen.io/miriamcc/pen/KzGGqZ
But I don't know how to calculate all settings in CSS, maybe someone have similar slider without JS or know how to increase slides number?
#EDIT
I fixed it myself:
codepen.io/m17ek/pen/LYQyzbo
Here you go:
for future calculations when you add another slide :
duplicate this
/* add slide id here */
#slide4:checked ~ .images .images-inner {
/* increase this by 100% */
margin-left: -300%;
}
/* add nth child after comma(,) near Color of bullets */
/* add nth child after comma(,) near Text of slides */
/* add this and replace 4 with child count and increase time after infinite by 4100ms */
#play1:checked ~ div .fake-radio .radio-btn:nth-child(4) {
animation: bullet 12300ms infinite 11300ms;
}
/* do like above for this as well */
#play1:checked ~ .labels .label:nth-child(4) {
animation: caption 12300ms infinite 11300ms;
}
.image {
width: 100%;
height: 200px;
}
.radio {
/*display: none;*/
}
.images {
overflow: hidden;
top: 0;
bottom: 0;
left: 0;
right: 0;
width: 100%;
}
.images-inner {
width: 500%;
transition: all 800ms cubic-bezier(0.770, 0.000, 0.175, 1.000);
transition-timing-function: cubic-bezier(0.770, 0.000, 0.175, 1.000);
}
.image-slide {
width: 20%;
float: left;
}
.image-slide,
.fake-radio,
.radio-btn {
transition: all 0.5s ease-out;
}
.fake-radio {
float: right;
}
/* Move slides overflowed container */
#slide1:checked ~ .images .images-inner {
margin-left: 0;
}
#slide2:checked ~ .images .images-inner {
margin-left: -100%;
}
#slide3:checked ~ .images .images-inner {
margin-left: -200%;
}
#slide4:checked ~ .images .images-inner {
margin-left: -300%;
}
/* Color of bullets */
#slide1:checked ~ div .fake-radio .radio-btn:nth-child(1),
#slide2:checked ~ div .fake-radio .radio-btn:nth-child(2),
#slide3:checked ~ div .fake-radio .radio-btn:nth-child(3),
#slide3:checked ~ div .fake-radio .radio-btn:nth-child(4){
background: red;
}
.radio-btn {
width: 9px;
height: 9px;
border-radius: 5px;
background: gray;
display: inline-block !important;
margin: 0 1px;
cursor: pointer;
}
/* Color of bullets - END */
/* Text of slides */
#slide1:checked ~ .labels .label:nth-child(1),
#slide2:checked ~ .labels .label:nth-child(2),
#slide3:checked ~ .labels .label:nth-child(3),
#slide4:checked ~ .labels .label:nth-child(4){
opacity: 1;
}
.label {
opacity: 0;
position: absolute;
}
/* Text of slides - END */
/* Calculate AUTOPLAY for BULLETS */
#keyframes bullet {
0%, 33.32333333333334% {
background: red;
}
33.333333333333336%, 100% {
background: gray;
}
}
#play1:checked ~ div .fake-radio .radio-btn:nth-child(1) {
animation: bullet 12300ms infinite -1000ms;
}
#play1:checked ~ div .fake-radio .radio-btn:nth-child(2) {
animation: bullet 12300ms infinite 3100ms;
}
#play1:checked ~ div .fake-radio .radio-btn:nth-child(3) {
animation: bullet 12300ms infinite 7200ms;
}
#play1:checked ~ div .fake-radio .radio-btn:nth-child(4) {
animation: bullet 12300ms infinite 11300ms;
}
/* Calculate AUTOPLAY for BULLETS - END */
/* Calculate AUTOPLAY for SLIDES */
#keyframes slide {
0%, 25.203252032520325% { margin-left: 0; }
33.333333333333336%, 58.53658536585366% { margin-left: -100%; }
66.66666666666667%, 91.869918699187% { margin-left: -200%; }
}
.st-slider > #play1:checked ~ .images .images-inner {
animation: slide 12300ms infinite;
}
/* Calculate AUTOPLAY for SLIDES - END */
/* Calculate AUTOPLAY for CAPTION */
#keyframes caption {
0%, 33.32333333333334% {
opacity: 1;
}
33.333333333333336%, 100% {
opacity: 0;
}
}
#play1:checked ~ .labels .label:nth-child(1) {
animation: caption 12300ms infinite -1000ms;
}
#play1:checked ~ .labels .label:nth-child(2) {
animation: caption 12300ms infinite 3100ms;
}
#play1:checked ~ .labels .label:nth-child(3) {
animation: caption 12300ms infinite 7200ms;
}
#play1:checked ~ .labels .label:nth-child(4) {
animation: caption 12300ms infinite 11300ms;
}
/* Calculate AUTOPLAY for CAPTION - END */
<h1>Pure CSS slider</h1><pre>(with Autoplay at the beginning)</pre><br>
<div id="homepage-slider" class="st-slider">
<input type="radio" class="cs_anchor radio" name="slider" id="slide1"/>
<input type="radio" class="cs_anchor radio" name="slider" id="slide2"/>
<input type="radio" class="cs_anchor radio" name="slider" id="slide3"/>
<input type="radio" class="cs_anchor radio" name="slider" id="slide4" checked=""/>
<div class="images">
<div class="images-inner">
<div class="image-slide">
<div class="image bg-yellow" style="background-color:yellow;">image slide 1</div>
</div>
<div class="image-slide">
<div class="image bg-blue" style="background-color:pink;">imager slide 2</div>
</div>
<div class="image-slide">
<div class="image bg-red" style="background-color:orange;">image slide 3</div>
</div>
<div class="image-slide">
<div class="image bg-blue" style="background-color:lightblue;">image slide 4</div>
</div>
</div>
</div>
<div class="labels">
<label for="slide1" class="label">text slide 1</label>
<label for="slide2" class="label">text slide 2</label>
<label for="slide3" class="label">text slide 3</label>
<label for="slide4" class="label">text slide 4</label>
<div class="fake-radio">
<label for="slide1" class="radio-btn"></label>
<label for="slide2" class="radio-btn"></label>
<label for="slide3" class="radio-btn"></label>
<label for="slide4" class="radio-btn"></label>
</div>
</div>
</div>
This question already has answers here:
How can I transition width of content with width: auto?
(2 answers)
Closed 1 year ago.
I expect it has something to do with the width: fit-content property not being a number, but I don't know how to fix it without using a fixed width. As you can see below, the divs don't expand smoothly when hovered over. Instead, they expand to 100% instantly.
* {
font-family: sans-serif;
}
div:not(#container) {
width: fit-content;
background-color: green;
color: white;
margin-top: 1em;
padding: 1em;
transition-property: width;
transition-duration: 1s;
}
#ease {
transition-timing-function: ease;
}
#linear {
transition-timing-function: linear;
}
#ease-in {
transition-timing-function: ease-in;
}
#ease-out {
transition-timing-function: ease-out;
}
#in-out {
transition-timing-function: ease-in-out;
}
#container:hover div {
width: 90%;
}
<html>
<head>
<title>CSS animations</title>
</head>
<body>
<div id="container">
<div id="linear">
<p>
Linear
</p>
</div>
<div id="ease">
<p>
Ease
</p>
</div>
<div id="ease-in">
<p>
In
</p>
</div>
<div id="ease-out">
<p>
Out
</p>
</div>
<div id="in-out">
<p>
In-out
</p>
</div>
</div>
</body>
</html>
Your assumption/expectation about width: fit-content seems reasonable to me. Until someone can explain better, you could use width: fit-content along with min-width: 0, then animate min-width. It's not perfect, since the animation begins at 0 (you may notice a slight delay)
* {
font-family: sans-serif;
}
div:not(#container) {
width: fit-content;
min-width: 0;
background-color: green;
color: white;
margin-top: 1em;
padding: 1em;
transition-property: min-width;
transition-duration: 1s;
}
#ease {
transition-timing-function: ease;
}
#linear {
transition-timing-function: linear;
}
#ease-in {
transition-timing-function: ease-in;
}
#ease-out {
transition-timing-function: ease-out;
}
#in-out {
transition-timing-function: ease-in-out;
}
#container:hover div {
min-width: 90%;
}
<html>
<head>
<title>CSS animations</title>
</head>
<body>
<div id="container">
<div id="linear">
<p>
Linear
</p>
</div>
<div id="ease">
<p>
Ease
</p>
</div>
<div id="ease-in">
<p>
In
</p>
</div>
<div id="ease-out">
<p>
Out
</p>
</div>
<div id="in-out">
<p>
In-out
</p>
</div>
</div>
</body>
</html>
Related question, regarding height: fit-content
I have a row of pictures where I want to fade in one image after another.
.jumbotron > div > div picture > img{
animation: fadein 6s;
-moz-animation: fadein 6s; /* Firefox */
-webkit-animation: fadein 6s; /* Safari and Chrome */
-o-animation: fadein 6s; /* Opera */
}
#keyframes fadein {
from {
opacity:0;
}
to {
opacity:1;
}
}
#-moz-keyframes fadein { /* Firefox */
from {
opacity:0;
}
to {
opacity:1;
}
}
#-webkit-keyframes fadein { /* Safari and Chrome */
from {
opacity:0;
}
to {
opacity:1;
}
}
#-o-keyframes fadein { /* Opera */
from {
opacity:0;
}
to {
opacity: 1;
}
}
This code let's all images fade in at the same time.
I'm using typo3 with a template, the html structure is a bit complicated because of this - I'm sorry.
<section class="jumbotron">
<div class="container">
<div class="row">
<div class="col-xs-12">
<div id="c1170" class="">
<div class="row">
<div class="col-xl-9 col-lg-9 col-md-9 col-sm-12 col-xs-12">
<div class=" ">
<div id="c1163" class="">
<div class="row">
<div class="col-xl-2 col-lg-2 col-md-2 col-sm-6 col-xs-6">
<div class=" ">
<div id="c1164" class="">
<div class="ce-textpic ce-left ce-above">
<div class="" >
<div class="row">
<div class=" col-xs-12 col-sm-12 col-md-12 col-lg-12 col-xl-12 ">
<div class="ce-media">
<picture alt="Geigen3D_m_02.gif">
<video style="display: none;"><![endif]-->
<![CDATA[ orig Width: 123px ]]>
<![CDATA[ xs scale: 0.5, 544px, max: 272px]]>
<source srcset="fileadmin/images/buecher/erzaehlungen/Geigen3D_m_02.gif" media="(max-width: 544px)">
<![CDATA[ sm scale: 0.5, 768px, max: 384px]]>
<source srcset="fileadmin/images/buecher/erzaehlungen/Geigen3D_m_02.gif" media="(max-width: 768px)">
<![CDATA[ md scale: 0.125, 992px, max: 124px]]>
<source srcset="fileadmin/images/buecher/erzaehlungen/Geigen3D_m_02.gif" media="(max-width: 992px)">
<![CDATA[ lg scale: 0.125, 1200px, max: 150px]]>
<source srcset="fileadmin/images/buecher/erzaehlungen/Geigen3D_m_02.gif" media="(min-width: 992px)">
</video><![endif]-->
<img src="fileadmin/images/buecher/erzaehlungen/Geigen3D_m_02.gif"
alt="Geigen3D_m_02.gif "
title=""
class="img-fluid m-b-1 " />
</picture>
</div>
</div>
<div class="clearfix hidden-sm-up"></div>
<div class="hidden-xs-down clearfix hidden-md-up"></div>
<div class="hidden-sm-down clearfix hidden-lg-up"></div>
<div class="hidden-md-down clearfix hidden-xl-up"></div>
<div class="hidden-lg-down clearfix"></div>
</div>
</div>
<div class="ce-bodytext">
</div>
</div>
</div>
</div>
</div>
<div class="col-xl-2 col-lg-2 col-md-2 col-sm-6 col-xs-6">
<div class=" ">
<div id="c1165" class="">
<div class="ce-textpic ce-left ce-above">
<div class="" >
<div class="row">
<div class=" col-xs-12 col-sm-12 col-md-12 col-lg-12 col-xl-12 ">
<div class="ce-media">
<!--next picture begins-->
<picture alt="image.gif">
and so on, and so on...
All solutions are welcome (pure css solution would be great tho), thank you for reading!
Here's a CSS-only solution using an approach similar to what you're starting with. I've simplified the HTML and CSS to focus on the important parts.
The General Idea
Layout your images as you desire. In this case I've used a <ul> element with <li> elements to hold the images, and laid them out horizontally.
Add a fadeIn animation to the images.
Now here's the key, add a animation-delay for each image, dependent on it's number in the lineup. The first will have no delay. The 2nd, a 3 second delay. The 3rd, a 6 second delay, and so on. This timing comes from the animation-duration of 3s. After the first image has faded in, the 2nd will fade in. After the 2nd has faded in, the 3rd will fade in, etc, etc.
Unknown Number of Images?
If the number of images is unknown this approach can still be used, though it will mean creating a few CSS styles that may never be used. You'll need to create:
li:nth-child(N) > img {
animation-delay: [animation-duration * N]s;
}
for the maximum number of images you think you'll have. So if you might have 100 images, and the animation-duration is set to 3s, you'll create 100 of those snippets, all the way through:
li:nth-child(100) > img {
animation-delay: 300s;
}
Demo
ul {
position: relative;
width: 100%
}
li {
float: left;
width: 25%;
}
img {
width: 100%;
opacity: 0;
animation-name: fadeIn;
animation-duration: 3s;
animation-iteration-count: 1;
animation-fill-mode: forwards;
}
li:nth-child(2) > img {
animation-delay: 3s;
}
li:nth-child(3) > img {
animation-delay: 6s;
}
li:nth-child(4) > img {
animation-delay: 9s;
}
li:nth-child(5) > img {
animation-delay: 12s;
}
li:nth-child(6) > img {
animation-delay: 15s;
}
li:nth-child(7) > img {
animation-delay: 18s;
}
li:nth-child(8) > img {
animation-delay:21s;
}
#keyframes fadeIn {
from {
opacity: 0;
}
to {
opacity: 1;
}
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/meyer-reset/2.0/reset.css" rel="stylesheet"/>
<ul>
<li><img src="http://placehold.it/400?text=1" /></li>
<li><img src="http://placehold.it/400?text=2" /></li>
<li><img src="http://placehold.it/400?text=3" /></li>
<li><img src="http://placehold.it/400?text=4" /></li>
<li><img src="http://placehold.it/400?text=5" /></li>
<li><img src="http://placehold.it/400?text=6" /></li>
<li><img src="http://placehold.it/400?text=7" /></li>
<li><img src="http://placehold.it/400?text=8" /></li>
</ul>
Here's the same demo on Codepen.
My proposal is to add an animation delay to every img (div in my example) increasingly. divs start with opacity:0; , attached in a class in this case, then we need some JavaScript to remove that opacity property once the animation has finished.
$('div').on('animationend', function() {
$(this).removeClass('initial');
})
.initial {
opacity: 0;
}
div {
width: 100px;
height: 100px;
background: pink;
border: 1px solid;
float: left;
animation: fadein 6s;
-moz-animation: fadein 6s;
/* Firefox */
-webkit-animation: fadein 6s;
/* Safari and Chrome */
-o-animation: fadein 6s;
/* Opera */
}
div:nth-child(1) {
animation-delay: 0s;
}
div:nth-child(2) {
animation-delay: 6s;
}
div:nth-child(3) {
animation-delay: 12s;
}
div:nth-child(4) {
animation-delay: 18s;
}
#keyframes fadein {
from {
opacity: 0;
}
to {
opacity: 1;
}
}
#-moz-keyframes fadein {
/* Firefox */
from {
opacity: 0;
}
to {
opacity: 1;
}
}
#-webkit-keyframes fadein {
/* Safari and Chrome */
from {
opacity: 0;
}
to {
opacity: 1;
}
}
#-o-keyframes fadein {
/* Opera */
from {
opacity: 0;
}
to {
opacity: 1;
}
}
<div class="initial"></div>
<div class="initial"></div>
<div class="initial"></div>
<div class="initial"></div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
I am making a website for a friend but since I'm still a beginner at this I'm not sure how to proceed. I'm making a simple intro page with his name and an enter button. The enter button has a hover function that when you hover your mouse over it it changes color, meanwhile I have a background div loop that iterates through 5 different backgrounds. My button and its hover function work fine on the first background picture, but once it changes the hover function no longer works until it comes back to that very first picture.
The background changing is a css code I found here on stack while I made everything else.
Here's My Code with what I'm working with.
Any ideas why the button hover isn't working on all the backgrounds?
HTML
<body class="intro-body">
<div id="background-change">
<div class="background-image image1">
<h1 class="intro-title">Name Here</h1>
<p class="intro-button intro-button-hover">Enter</p>
</div>
<div class="background-image image2">
<h1 class="intro-title">Name Here</h1>
<p class="intro-button intro-button-hover">Enter</p>
</div>
<div class="background-image image3">
<h1 class="intro-title">Name Here</h1>
<p class="intro-button intro-button-hover">Enter</p>
</div>
<div class="background-image image4">
<h1 class="intro-title">Name Here</h1>
<p class="intro-button intro-button-hover">Enter</p>
</div>
<div class="background-image image5">
<h1 class="intro-title">Name Here</h1>
<p class="intro-button intro-button-hover">Enter</p>
</div>
</div>
</body>
CSS
.intro-body {
text-align: center;
background-repeat: no-repeat;
background-position: center;
}
.intro-title {
padding-top: 20vh;
padding-bottom: 5vh;
font-size: 650%;
text-transform: uppercase;
text-align: center;
color: white;
letter-spacing: 5px;
text-shadow: 2px 2px black;
}
.intro-button {
border: solid;
color: white;
padding: 20px 45px;
display: inline-block;
letter-spacing: 2px;
text-align: center;
text-transform: uppercase;
cursor: pointer;
}
p.intro-button-hover:hover {
background-color: white;
opacity: 0.85;
padding: 23px 48px;
letter-spacing: 2px;
text-align: center;
text-transform: uppercase;
color: black;
border: unset;
cursor: pointer;
}
.background-image {
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
position: absolute;
top: 0;
left: 0;
height: 100%;
width: 100%;
}
.image1{
background: url("http://placekitten.com/1200/1200") no-repeat center fixed;
}
.image2{
background: url("http://placekitten.com/1200/1300") no-repeat center fixed;
}
.image3{
background: url("http://placekitten.com/1300/1200") no-repeat center fixed;
}
.image4{
background: url("http://placekitten.com/1300/1300") no-repeat center fixed;
}
.image5{
background: url("http://placekitten.com/1300/1400") no-repeat center fixed;
}
#keyframes backgroundchangeFadeInOut {
0% {
opacity:1;
}
17% {
opacity:1;
}
25% {
opacity:0;
}
92% {
opacity:0;
}
100% {
opacity:1;
}
}
#-webkit-keyframes backgroundchangeFadeInOut {
0% {
opacity:1;
}
17% {
opacity:1;
}
25% {
opacity:0;
}
92% {
opacity:0;
}
100% {
opacity:1;
}
}
#background-change div:nth-of-type(1) {
animation-delay: 20s;
-webkit-animation-delay: 20s;
}
#background-change div:nth-of-type(2) {
animation-delay: 15s;
-webkit-animation-delay: 15s;
}
#background-change div:nth-of-type(3) {
animation-delay: 10s;
-webkit-animation-delay: 10s;
}
#background-change div:nth-of-type(4) {
animation-delay: 5s;
-webkit-animation-delay: 5s;
}
#background-change div:nth-of-type(5) {
animation-delay: 0s;
-webkit-animation-delay: 0s;
}
#background-change div {
animation-name: backgroundchangeFadeInOut;
animation-timing-function: ease-in-out;
animation-iteration-count: infinite;
animation-duration: 25s;
-webkit-animation-name: backgroundchangeFadeInOut;
-webkit-animation-timing-function: ease-in-out;
-webkit-animation-iteration-count: infinite;
-webkit-animation-duration: 25s;
}
Just update with the following code, I have just added internal js.
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("p").mouseover(function(){
$("p").css("background-color", "white");
});
$("p").mouseout(function(){
$("p").css("background-color", "");
$("p").css("color", "black");
});
});
And remove the properties with '//' in the css:
p.intro-button-hover:hover {
// background-color: #fff;
//opacity: 0.4;
padding: 23px 48px;
letter-spacing: 2px;
text-align: center;
text-transform: uppercase;
//color: black;
border: unset;
cursor: pointer;
}
Quickly looking at this, the reason for it is that you actually have 5 different buttons fading in and out, which messes things up.
Do something like this (pseudocode)
<body class="intro-body">
<div id="callout">
<h1 class="intro-title">Name Here</h1>
<button class="intro-button intro-button-hover">Enter</button>
</div>
<div id="background-change">
<div class="background-image image1"></div>
<div class="background-image image2"></div>
<div class="background-image image3"></div>
<div class="background-image image4"></div>
<div class="background-image image5"></div>
</div>
</body>
Naturally position the callout section over the background image and you're good to go.
I have gone through your code and tried debugging the problem. The problem is mostly from your animation code. Try rewriting your animation code. I have tested it removing the animation code, to check if the hover is working properly or not, and it works fine. There is also a bug with your animation code which makes the Enter button disappear for a while after the first animation iteration and appear again after few seconds.
If possible try using JQuery, as it makes your job easier for using animations. For example, can simply use fadeIn(); and fadeOut(); functions for the animation you have been doing in your CSS animation code.
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;}
}