Hello I am creating an HTML and CSS slideshow with four sets of images that have four pictures in each. It works perfectly on the first cycle, but after that the images start disappearing and reappearing in strange timings. I have created a JSFiddle to illustrate what I mean..... https://jsfiddle.net/mattmega4/12Lt9yhh/
<figure>
<img src="assets/fourBackgrounds/goal.jpg" width="45%" height="auto"
/>
</figure>
<figure>
<img src="assets/fourBackgrounds/soldierCat.jpg" width="45%"
height="auto" />
</figure>
</div>
<div class="css-slideshow1">
<figure>
<img src="assets/fourBackgrounds/Cyrus.jpg" width="45%" height="auto"
/>
</figure>
<figure>
<img src="assets/fourBackgrounds/fire.jpg" width="45%" height="auto"
/>
</figure>
<figure>
<img src="assets/fourBackgrounds/goal.jpg" width="45%" height="auto"
/>
</figure>
<figure>
<img src="assets/fourBackgrounds/soldierCat.jpg" width="45%"
height="auto" />
</figure>
</div>
<div class="css-slideshow2">
<figure>
<img src="assets/fourBackgrounds/Cyrus.jpg" width="45%" height="auto"
/>
</figure>
<figure>
<img src="assets/fourBackgrounds/fire.jpg" width="45%" height="auto"
/>
</figure>
<figure>
<img src="assets/fourBackgrounds/goal.jpg" width="45%" height="auto"
/>
</figure>
<figure>
<img src="assets/fourBackgrounds/soldierCat.jpg" width="45%"
height="auto" />
</figure>
</div>
<div class="css-slideshow3">
<figure>
<img src="assets/fourBackgrounds/Cyrus.jpg" width="45%"
height="auto" />
</figure>
<figure>
<img src="assets/fourBackgrounds/fire.jpg" width="45%" height="auto"
/>
</figure>
<figure>
<img src="assets/fourBackgrounds/goal.jpg" width="45%" height="auto"
/>
</figure>
<figure>
<img src="assets/fourBackgrounds/soldierCat.jpg" width="45%"
height="auto" />
</figure>
</div>
</div>
.css-slideshow {
position: relative;
width: 100%;
height: auto;
}
.css-slideshow figure {
margin: 0;
width: 100%;
height: auto;
position: absolute;
}
.css-slideshow img {
-webkit-box-shadow: 0 0 2px #666;
box-shadow: 0 0 2px #666;
}
.css-slideshow figcaption {
position: absolute;
top: 5px;
color: #fff;
background: rgba(0,0,0, .3);
font-size: .8em;
padding: 8px 12px;
filter: alpha(opacity=0);
opacity: 0;
-webkit-transition: opacity .5s;
transition: opacity .5s;
}
.css-slideshow-attr {
max-width: 530px;
text-align: right;
font-size: .7em;
font-style: italic;
}
.css-slideshow-attr a {
color: #666;
}
.css-slideshow figure:nth-child(1) {
-webkit-animation: xfade 42s 39s infinite;
animation: xfade 42s 39s infinite;
}
.css-slideshow figure:nth-child(2) {
-webkit-animation: xfade 42s 27s infinite;
animation: xfade 42s 27s infinite;
}
.css-slideshow figure:nth-child(3) {
-webkit-animation: xfade 42s 15s infinite;
animation: xfade 42s 15s infinite;
}
.css-slideshow figure:nth-child(4) {
-webkit-animation: xfade 42s 3s infinite;
animation: xfade 42s 3s infinite;
}
.css-slideshow1 {
position: relative;
max-width: 100%;
height: auto;
}
.css-slideshow1 figure {
margin: 0;
width: 100%;
height: auto;
margin-left: 50%;
position: absolute;
}
.css-slideshow1 img {
-webkit-box-shadow: 0 0 2px #666;
box-shadow: 0 0 2px #666;
}
.css-slideshow1 figcaption {
position: absolute;
top: 5px;
color: #fff;
background: rgba(0,0,0, .3);
font-size: .8em;
padding: 8px 12px;
filter: alpha(opacity=0);
opacity: 0;
-webkit-transition: opacity .5s;
transition: opacity .5s;
}
.css-slideshow1-attr {
max-width: 530px;
text-align: right;
font-size: .7em;
font-style: italic;
}
.css-slideshow1-attr a {
color: #666;
}
.css-slideshow1 figure:nth-child(1) {
-webkit-animation: xfade 45s 42s infinite;
animation: xfade 45s 42s infinite;
}
.css-slideshow1 figure:nth-child(2) {
-webkit-animation: xfade 45s 30s infinite;
animation: xfade 45s 30s infinite;
}
.css-slideshow1 figure:nth-child(3) {
-webkit-animation: xfade 45s 18s infinite;
animation: xfade 45s 18s infinite;
}
.css-slideshow1 figure:nth-child(4) {
-webkit-animation: xfade 45s 6s infinite;
animation: xfade 45s 6s infinite;
}
.css-slideshow2 {
position: relative;
width: 100%;
height: auto;
}
.css-slideshow2 figure {
margin: 0;
width: 100%;
margin-top: 50%;
height: auto;
position: absolute;
}
.css-slideshow2 img {
-webkit-box-shadow: 0 0 2px #666;
box-shadow: 0 0 2px #666;
}
.css-slideshow2 figcaption {
position: absolute;
top: 5px;
color: #fff;
background: rgba(0,0,0, .3);
font-size: .8em;
padding: 8px 12px;
filter: alpha(opacity=0);
opacity: 0;
-webkit-transition: opacity .5s;
transition: opacity .5s;
}
.css-slideshow2-attr {
max-width: 530px;
text-align: right;
font-size: .7em;
font-style: italic;
}
.css-slideshow2-attr a {
color: #666;
}
.css-slideshow2 figure:nth-child(1) {
-webkit-animation: xfade 48s 45s infinite;
animation: xfade 48s 45s infinite;
}
.css-slideshow2 figure:nth-child(2) {
-webkit-animation: xfade 48s 33s infinite;
animation: xfade 48s 33s infinite;
}
.css-slideshow2 figure:nth-child(3) {
-webkit-animation: xfade 48s 21s infinite;
animation: xfade 48s 21s infinite;
}
.css-slideshow2 figure:nth-child(4) {
-webkit-animation: xfade 48s 9s infinite;
animation: xfade 48s 9s infinite;
}
.css-slideshow3 {
position: relative;
max-width: 100%;
height: auto;
}
.css-slideshow3 figure {
margin: 0;
width: 100%;
margin-left: 50%;
margin-top: 50%;
height: auto;
margin-left: 50%;
position: absolute;
}
.css-slideshow3 img {
-webkit-box-shadow: 0 0 2px #666;
box-shadow: 0 0 2px #666;
}
.css-slideshow3 figcaption {
position: absolute;
top: 5px;
color: #fff;
background: rgba(0,0,0, .3);
font-size: .8em;
padding: 8px 12px;
filter: alpha(opacity=0);
opacity: 0;
-webkit-transition: opacity .5s;
transition: opacity .5s;
}
.css-slideshow3-attr {
max-width: 530px;
text-align: right;
font-size: .7em;
font-style: italic;
}
.css-slideshow3-attr a {
color: #666;
}
.css-slideshow3 figure:nth-child(1) {
-webkit-animation: xfade 51s 48s infinite;
animation: xfade 51s 48s infinite;
}
.css-slideshow3 figure:nth-child(2) {
-webkit-animation: xfade 51s 36s infinite;
animation: xfade 51s 36s infinite;
}
.css-slideshow3 figure:nth-child(3) {
-webkit-animation: xfade 51s 24s infinite;
animation: xfade 51s 24s infinite;
}
.css-slideshow3 figure:nth-child(4) {
-webkit-animation: xfade 51s 12s infinite;
animation: xfade 51s 12s infinite;
}
#-webkit-keyframes "xfade" {
0% {
filter: alpha(opacity=100);
opacity: 1;
}
14.67% {
filter: alpha(opacity=100);
opacity: 1;
}
16.67% {
filter: alpha(opacity=0);
opacity: 0;
}
98% {
filter: alpha(opacity=0);
opacity: 0;
}
100% {
filter: alpha(opacity=100);
opacity: 1;
}
}
.image-slideshow{
padding-top: 3.5%;
padding-left: 5.5%;
}
Can somebody elaborate on what I need to add or remove or edit in order for this to work as it should. Thank you
Related
I want to show login form on the top of cloud bakground. I copy cloud backgroud script from this link . In css .cloud I change position from relative to absolute but login form not move on the top of cloud.
This is my code I paste cloud backgroud script before login form.
* {
margin: 0;
padding: 0;
}
body {
/*To hide the horizontal scroller appearing during the animation*/
overflow: hidden;
}
#clouds {
padding: 100px 0;
#background: #c9dbe9;
#background: -webkit-linear-gradient(top, #c9dbe9 0%, #fff 100%);
#background: -linear-gradient(top, #c9dbe9 0%, #fff 100%);
#background: -moz-linear-gradient(top, #c9dbe9 0%, #fff 100%);
}
/*Time to finalise the cloud shape*/
.cloud {
width: 200px;
height: 60px;
background: #fff;
border-radius: 200px;
-moz-border-radius: 200px;
-webkit-border-radius: 200px;
position: absolute;
}
.cloud:before,
.cloud:after {
content: '';
position: absolute;
background: #fff;
width: 100px;
height: 80px;
position: absolute;
top: -15px;
left: 10px;
border-radius: 100px;
-moz-border-radius: 100px;
-webkit-border-radius: 100px;
-webkit-transform: rotate(30deg);
transform: rotate(30deg);
-moz-transform: rotate(30deg);
}
.cloud:after {
width: 120px;
height: 120px;
top: -55px;
left: auto;
right: 15px;
}
/*Time to animate*/
.x1 {
-webkit-animation: moveclouds 15s linear infinite;
-moz-animation: moveclouds 15s linear infinite;
-o-animation: moveclouds 15s linear infinite;
}
/*variable speed, opacity, and position of clouds for realistic effect*/
.x2 {
left: 200px;
-webkit-transform: scale(0.6);
-moz-transform: scale(0.6);
transform: scale(0.6);
opacity: 0.6;
/*opacity proportional to the size*/
/*Speed will also be proportional to the size and opacity*/
/*More the speed. Less the time in 's' = seconds*/
-webkit-animation: moveclouds 25s linear infinite;
-moz-animation: moveclouds 25s linear infinite;
-o-animation: moveclouds 25s linear infinite;
}
.x3 {
left: -250px;
top: -200px;
-webkit-transform: scale(0.8);
-moz-transform: scale(0.8);
transform: scale(0.8);
opacity: 0.8;
/*opacity proportional to the size*/
-webkit-animation: moveclouds 20s linear infinite;
-moz-animation: moveclouds 20s linear infinite;
-o-animation: moveclouds 20s linear infinite;
}
.x4 {
left: 470px;
top: -250px;
-webkit-transform: scale(0.75);
-moz-transform: scale(0.75);
transform: scale(0.75);
opacity: 0.75;
/*opacity proportional to the size*/
-webkit-animation: moveclouds 18s linear infinite;
-moz-animation: moveclouds 18s linear infinite;
-o-animation: moveclouds 18s linear infinite;
}
.x5 {
left: -150px;
top: -150px;
-webkit-transform: scale(0.8);
-moz-transform: scale(0.8);
transform: scale(0.8);
opacity: 0.8;
/*opacity proportional to the size*/
-webkit-animation: moveclouds 20s linear infinite;
-moz-animation: moveclouds 20s linear infinite;
-o-animation: moveclouds 20s linear infinite;
}
#-webkit-keyframes moveclouds {
0% {
margin-left: 1000px;
}
100% {
margin-left: -1000px;
}
}
#-moz-keyframes moveclouds {
0% {
margin-left: 1000px;
}
100% {
margin-left: -1000px;
}
}
#-o-keyframes moveclouds {
0% {
margin-left: 1000px;
}
100% {
margin-left: -1000px;
}
}
<div id="clouds">
<div class="cloud x1"></div>
<!-- Time for multiple clouds to dance around -->
<div class="cloud x2"></div>
<div class="cloud x3"></div>
<div class="cloud x4"></div>
<div class="cloud x5"></div>
</div>
<!-- ************ This is my login form ************ -->
<div id="authloginContainer">
<div class="authloginTabContent" authpluginarray="1,2,3" modelnum="0">
<div class="authmodel authmodel_0 blueColorContainer">
<p> </p>
<div class="marbom6 usernameContainer">
<p class="pContainer authinputwidth">
<label></label>
<input id="username" value="Account" emptytip="Account" type="text" class="frm-input"></p>
</div>
<div class="marbom6 passwordContainer" style="margin-bottom: 0;">
<p class="center pContainer authinputwidth">
<label></label>
<input id="password" value="Password" emptytip="Password" type="text" class="frm-input"></p>
</div>
<div class="rmbPwdContainer" style="display: none;margin: 0 auto;width: 270px;">
<p class="center yaHei" style="text-align:left;padding-left: 24px;">
<input id="rememberPwd" name="rememberPwd" type="checkbox" savetime="14" onclick="selectRememberPwd()" class="remPwdInp">Remember password</p>
</div>
<div class="validcodeContainer authenticationcodeContainer" style="margin-top: 10px; display: block;">
<p class="pContainer authinputwidth">
<input id="validCode" value="Verification code" type="text" class="frm-input" onkeydown="subLoginCheck()" data-type="" style="" emptytip="Verification code" validcodecomplex="2" validcodelength="4"></p>
</div>
<p style="margin-top: 5px; text-align: center">
<input id="loginBtn" type="button" value="Log In" class="frm-button borderRadius4" style="background-color: #95F4FF; border-color: #95F4FF;" onclick="login()"></p>
</p>
<p> </p>
</div>
</div>
</div>
How to show login form on the top of cloud background ?
Change the position of the form :)
Something like this
#authloginContainer {
position: fixed;
width: 200px;
top: 50px;
left: calc(50% - 100px);
}
* {
margin: 0;
padding: 0;
}
body {
/*To hide the horizontal scroller appearing during the animation*/
overflow: hidden;
}
#clouds {
padding: 100px 0;
background: #c9dbe9;
background: -webkit-linear-gradient(top, #c9dbe9 0%, #fff 100%);
background: -linear-gradient(top, #c9dbe9 0%, #fff 100%);
background: -moz-linear-gradient(top, #c9dbe9 0%, #fff 100%);
}
#authloginContainer {
position: fixed;
width: 200px;
top: 50px;
left: calc(50% - 100px);
}
/*Time to finalise the cloud shape*/
.cloud {
width: 200px;
height: 60px;
background: #fff;
border-radius: 200px;
-moz-border-radius: 200px;
-webkit-border-radius: 200px;
position: absolute;
}
.cloud:before,
.cloud:after {
content: '';
position: absolute;
background: #fff;
width: 100px;
height: 80px;
position: absolute;
top: -15px;
left: 10px;
border-radius: 100px;
-moz-border-radius: 100px;
-webkit-border-radius: 100px;
-webkit-transform: rotate(30deg);
transform: rotate(30deg);
-moz-transform: rotate(30deg);
}
.cloud:after {
width: 120px;
height: 120px;
top: -55px;
left: auto;
right: 15px;
}
/*Time to animate*/
.x1 {
-webkit-animation: moveclouds 15s linear infinite;
-moz-animation: moveclouds 15s linear infinite;
-o-animation: moveclouds 15s linear infinite;
}
/*variable speed, opacity, and position of clouds for realistic effect*/
.x2 {
left: 200px;
-webkit-transform: scale(0.6);
-moz-transform: scale(0.6);
transform: scale(0.6);
opacity: 0.6;
/*opacity proportional to the size*/
/*Speed will also be proportional to the size and opacity*/
/*More the speed. Less the time in 's' = seconds*/
-webkit-animation: moveclouds 25s linear infinite;
-moz-animation: moveclouds 25s linear infinite;
-o-animation: moveclouds 25s linear infinite;
}
.x3 {
left: -250px;
top: -200px;
-webkit-transform: scale(0.8);
-moz-transform: scale(0.8);
transform: scale(0.8);
opacity: 0.8;
/*opacity proportional to the size*/
-webkit-animation: moveclouds 20s linear infinite;
-moz-animation: moveclouds 20s linear infinite;
-o-animation: moveclouds 20s linear infinite;
}
.x4 {
left: 470px;
top: -250px;
-webkit-transform: scale(0.75);
-moz-transform: scale(0.75);
transform: scale(0.75);
opacity: 0.75;
/*opacity proportional to the size*/
-webkit-animation: moveclouds 18s linear infinite;
-moz-animation: moveclouds 18s linear infinite;
-o-animation: moveclouds 18s linear infinite;
}
.x5 {
left: -150px;
top: -150px;
-webkit-transform: scale(0.8);
-moz-transform: scale(0.8);
transform: scale(0.8);
opacity: 0.8;
/*opacity proportional to the size*/
-webkit-animation: moveclouds 20s linear infinite;
-moz-animation: moveclouds 20s linear infinite;
-o-animation: moveclouds 20s linear infinite;
}
#-webkit-keyframes moveclouds {
0% {
margin-left: 1000px;
}
100% {
margin-left: -1000px;
}
}
#-moz-keyframes moveclouds {
0% {
margin-left: 1000px;
}
100% {
margin-left: -1000px;
}
}
#-o-keyframes moveclouds {
0% {
margin-left: 1000px;
}
100% {
margin-left: -1000px;
}
}
<div id="clouds">
<div class="cloud x1"></div>
<!-- Time for multiple clouds to dance around -->
<div class="cloud x2"></div>
<div class="cloud x3"></div>
<div class="cloud x4"></div>
<div class="cloud x5"></div>
</div>
<!-- ************ This is my login form ************ -->
<div id="authloginContainer">
<div class="authloginTabContent" authpluginarray="1,2,3" modelnum="0">
<div class="authmodel authmodel_0 blueColorContainer">
<p> </p>
<div class="marbom6 usernameContainer">
<p class="pContainer authinputwidth">
<label></label>
<input id="username" value="Account" emptytip="Account" type="text" class="frm-input"></p>
</div>
<div class="marbom6 passwordContainer" style="margin-bottom: 0;">
<p class="center pContainer authinputwidth">
<label></label>
<input id="password" value="Password" emptytip="Password" type="text" class="frm-input"></p>
</div>
<div class="rmbPwdContainer" style="display: none;margin: 0 auto;width: 270px;">
<p class="center yaHei" style="text-align:left;padding-left: 24px;">
<input id="rememberPwd" name="rememberPwd" type="checkbox" savetime="14" onclick="selectRememberPwd()" class="remPwdInp">Remember password</p>
</div>
<div class="validcodeContainer authenticationcodeContainer" style="margin-top: 10px; display: block;">
<p class="pContainer authinputwidth">
<input id="validCode" value="Verification code" type="text" class="frm-input" onkeydown="subLoginCheck()" data-type="" style="" emptytip="Verification code" validcodecomplex="2" validcodelength="4"></p>
</div>
<p style="margin-top: 5px; text-align: center">
<input id="loginBtn" type="button" value="Log In" class="frm-button borderRadius4" style="background-color: #95F4FF; border-color: #95F4FF;" onclick="login()"></p>
</p>
<p> </p>
</div>
</div>
</div>
I would like to use this image slider: http://codepen.io/rslglover/pen/DBvoA
The image slider works well, but when its finish, it stops. I can't see whats the difference is from the CodePen codes, and what I've done. How can it be it works in the CodePen link?
article{
position: absolute;
left: 450px;
background: #292929;
color: #e3e3e3;
width: 450px;
height: 450px;
text-align: center;
font: 2em/1em sans-serif;
border-box: box-sizing;
padding-top: 0px;
}
article:nth-of-type(1){
animation: slideIn 50s linear 0s infinite;
}
article:nth-of-type(2){
animation: slideIn 50s linear 5s infinite;
}
article:nth-of-type(3){
animation: slideIn 50s linear 10s infinite;
}
article:nth-of-type(4){
animation: slideIn 50s linear 15s infinite;
}
article:nth-of-type(5){
animation: slideIn 50s linear 20s infinite;
}
article:nth-of-type(6){
animation: slideIn 50s linear 25s infinite;
}
article:nth-of-type(7){
animation: slideIn 50s linear 30s infinite;
}
article:nth-of-type(8){
animation: slideIn 50s linear 35s infinite;
}
article:nth-of-type(9){
animation: slideIn 50s linear 40s infinite;
}
article:nth-of-type(10){
animation: slideIn 50s linear 45s infinite;
}
#keyframes slideIn{
0% {left: 450px;}
1% {left: 0;}
10% {left: 0;}
11% {left: -450px;}
100%{left: -450px;}
}
.galleryImg {
height: 450px;
width: 450px;
}
.gallery {
width: 450px;
height: 450px;
position: absolute;
left: 50%;
top: 50%;
margin-left: -225px;
margin-top: -225px;
overflow: hidden;
background: rgba(0,0,0,0.3);
border: 1px solid #fff;
box-shadow:5px 5px 5px 5px rgba(0,0,0,0.7);
}
And my html
<div class="galleryInfo">
<div class="gallery">
<article><img class="galleryImg" src="images/aa2.png" alt=""></article>
<article> <img class="galleryImg" src="images/aa1.png" alt=""></article>
<article><img class="galleryImg" src="images/bb1.png" alt=""></article>
<article><img class="galleryImg" src="images/bb2.png" alt=""></article>
</div>
</div>
Check this out:
HTML:
<div class="galleryInfo">
<div class="gallery">
<section>
<article><img src="https://image.freepik.com/free-icon/medical-samples-in-test-tubes-couple_318-61810.jpg" /></article>
<article><img src="https://image.freepik.com/free-icon/medical-samples-in-test-tubes-couple_318-61810.jpg" /></article>
<article><img src="https://image.freepik.com/free-icon/medical-samples-in-test-tubes-couple_318-61810.jpg" /></article>
<article><img src="https://image.freepik.com/free-icon/medical-samples-in-test-tubes-couple_318-61810.jpg" /></article>
</section>
</div>
</div>
CSS:
html{
background: #aaa;
}
section{
width: 200px;
height: 200px;
position: relative;
left: 50%;
top: 1em;
margin-left: -100px;
overflow: hidden;
background: #292929;
border: 10px solid #fff;
}
/*section:hover article{
animation-play-state: paused;
}*/
article{
position: absolute;
left: 450px;
background: #292929;
color: #e3e3e3;
width: 450px;
height: 450px;
text-align: center;
font: 2em/1em sans-serif;
border-box: box-sizing;
padding-top: 0px;
}
.galleryImg {
height: 450px;
width: 450px;
}
.gallery {
width: 450px;
height: 450px;
position: absolute;
left: 50%;
top: 50%;
margin-left: -225px;
margin-top: -225px;
overflow: hidden;
background: rgba(0,0,0,0.3);
border: 1px solid #fff;
box-shadow:5px 5px 5px 5px rgba(0,0,0,0.7);
}
article:nth-of-type(1){
animation: slideIn 20s linear 0s infinite;
}
article:nth-of-type(2){
animation: slideIn 20s linear 5s infinite;
}
article:nth-of-type(3){
animation: slideIn 20s linear 10s infinite;
}
article:nth-of-type(4){
animation: slideIn 20s linear 15s infinite;
}
#keyframes slideIn{
0% {left: 200px;}
1% {left: 0;}
10% {left: 0;}
11% {left: -200px;}
100%{left: -200px;}
}
Or change position in css file clas galleryInfo and gallery above animation.
The primary reason why your animation appears to stop, is because the CSS is structured for 10 slides.
To maintain the same duration and animation, the keyframes percentages need to be configured for the new total number of slides you are using.
#keyframes slideIn{
0% {left: 200px;} /* Always 0% */
2.5% {left: 0;} /* Equivalent of 0.5s e.g. 0.5/maxTime*100 */
25% {left: 0;} /* Equivalent of 5s e.g. 5/maxTime*100 */
27.5% {left: -200px;} /* Equivalent of 5.5s e.g. 5.5/maxTime*100 */
100%{left: -200px;} /* Always 100% */
}
By changing the keyframes, you will maintain the same slide speed as your codepen example had.
Here is a working snippet.
html{
background: #aaa;
}
section{
width: 200px;
height: 200px;
position: relative;
left: 50%;
top: 1em;
margin-left: -100px;
overflow: hidden;
background: #292929;
border: 10px solid #fff;
}
/*section:hover article{
animation-play-state: paused;
}*/
article{
position: absolute;
left: 200px;
background: #292929;
color: #e3e3e3;
width: 200px;
height: 200px;
text-align: center;
font: 2em/1em sans-serif;
border-box: box-sizing;
padding-top: 80px;
}
/*
* As each slide's animation is 5s, the set duration is totalSlides * 5.
*/
article:nth-of-type(1){
animation: slideIn 20s linear 0s infinite;
}
article:nth-of-type(2){
animation: slideIn 20s linear 5s infinite;
}
article:nth-of-type(3){
animation: slideIn 20s linear 10s infinite;
}
article:nth-of-type(4){
animation: slideIn 20s linear 15s infinite;
}
#keyframes slideIn{
0% {left: 200px;} /* Always 0% */
2.5% {left: 0;} /* Equivalent of 0.5s e.g. 0.5/maxTime*100 */
25% {left: 0;} /* Equivalent of 5s e.g. 5/maxTime*100 */
27.5% {left: -200px;} /* Equivalent of 5.5s e.g. 5.5/maxTime*100 */
100%{left: -200px;} /* Always 100% */
}
<section>
<article>Slide 1</article>
<article>Slide 2</article>
<article>Slide 3</article>
<article>Slide 4</article>
</section>
I'm trying to get this CSS alternative for a slide show animation for customer Testimonials. I can get it to work in IE and Firefox but it will not work in Chrome. Does anybody know if i need to use some prefixes to fix this issue?
Here is a Demo.
<div class="css-slideshow">
<figure>
<img src="http://www.offsetprinting.com/img/custom_images/test_slide1.jpg" alt="class-header-css3" width="1192" height="497" class="alignnone size-full wp-image-172" /><figcaption><strong>CSS3:</strong></figcaption>
</figure>
<figure>
<img src="http://www.offsetprinting.com/img/custom_images/test_slide2.jpg" alt="class-header-semantics" width="1192" height="497" class="alignnone size-full wp-image-179" /><figcaption><strong>Semantics:</strong></figcaption>
</figure>
<figure>
<img src="http://www.offsetprinting.com/img/custom_images/test_slide3.jpg" alt="class-header-offline" width="1192" height="497" class="alignnone size-large wp-image-178" /><figcaption><strong>Offline & Storage:</strong></figcaption>
</figure>
<figure>
<img src="http://www.offsetprinting.com/img/custom_images/test_slide1.jpg" alt="class-header-device" width="1192" height="497" class="alignnone size-full wp-image-177" /><figcaption><strong>Device Access:</strong></figcaption>
</figure>
<figure>
<img src="http://www.offsetprinting.com/img/custom_images/test_slide2.jpg" alt="class-header-connectivity" width="1192" height="497" class="alignnone size-large wp-image-176" /><figcaption><strong>Connectivity:</strong></figcaption>
</figure>
<figure>
<img src="http://www.offsetprinting.com/img/custom_images/test_slide3.jpg" alt="class-header-multimedia" width="1192" height="497" class="alignnone size-large wp-image-175" /><figcaption><strong>Multimedia:</strong></figcaption>
</figure>
<figure>
<img src="http://www.offsetprinting.com/img/custom_images/test_slide1.jpg" alt="class-header-3d" width="1192" height="497" class="alignnone size-large wp-image-174" /><figcaption><strong>3D, Graphics & Effects:</strong></figcaption>
</figure>
<figure>
<img src="http://www.offsetprinting.com/img/custom_images/test_slide2.jpg" alt="class-header-performance" width="1192" height="497" class="alignnone size-large wp-image-173" /><figcaption><strong>Performance & Integration:</strong></figcaption>
</figure>
</div>
body{
font-family: "HelveticaNeue-Light", "Helvetica Neue Light", "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif;
font-weight: 300;
}
.css-slideshow{
position: relative;
max-width: 1192px;
height: 497px;
margin: 5em auto .5em auto;
}
.css-slideshow figure{
margin: 0;
max-width: 1192px;
height: 497px;
background: #000;
position: absolute;
}
.css-slideshow img{
box-shadow: 0 0 2px #666;
}
.css-slideshow figcaption{
position: absolute;
top: 0;
color: #fff;
background: rgba(0,0,0, .3);
font-size: .8em;
padding: 8px 12px;
opacity: 0;
transition: opacity .5s;
}
.css-slideshow-attr{
max-width: 1192px;
text-align: right;
font-size: .7em;
font-style: italic;
margin:0 auto;
}
.css-slideshow-attr a{
color: #666;
}
.css-slideshow figure{
opacity:0;
}
figure:nth-child(1) {
animation: xfade 48s 42s infinite;
}
figure:nth-child(2) {
animation: xfade 48s 36s infinite;
}
figure:nth-child(3) {
animation: xfade 48s 30s infinite;
}
figure:nth-child(4) {
animation: xfade 48s 24s infinite;
}
figure:nth-child(5) {
animation: xfade 48s 18s infinite;
}
figure:nth-child(6) {
animation: xfade 48s 12s infinite;
}
figure:nth-child(7) {
animation: xfade 48s 6s infinite;
}
figure:nth-child(8) {
animation: xfade 48s 0s infinite;
}
#keyframes xfade{
0%{
opacity: 1;
}
10.5% {
opacity: 1;
}
12.5%{
opacity: 0;
}
98% {
opacity: 0;
}
100% {
opacity: 1;
}
}
</
Chrome is a webkit browser, try using the webkit prefix (http://www.w3schools.com/cssref/css3_pr_animation-keyframes.asp) like this:
figure:nth-child(8) {
animation: xfade 48s 0s infinite;
-webkit-animation: xfade 48s 0s infinite;
}
#-webkit-keyframes xfade{
0%{
opacity: 1;
}
10.5% {
opacity: 1;
}
12.5%{
opacity: 0;
}
98% {
opacity: 0;
}
100% {
opacity: 1;
}
}
#keyframes xfade{
0%{
opacity: 1;
}
10.5% {
opacity: 1;
}
12.5%{
opacity: 0;
}
98% {
opacity: 0;
}
100% {
opacity: 1;
}
}
As shown in the codepen below, the nav a links fade in as they should, but then when hovered they seem to replay the animation in reverse and then forward again really quickly. It's really odd. http://codepen.io/mildrenben/pen/wBMVdm
<header>
<h1>BEN MILDREN</h1>
<p>Designer and Developer</p>
</header>
<nav>
<a>About</a>
<a>Portfolio</a>
<a>Blog</a>
<a>Contact</a>
</nav>
<link href='http://fonts.googleapis.com/css?family=Open+Sans:400,600,300,700,800|Gentium+Book+Basic:400,400italic,700italic' rel='stylesheet' type='text/css'>
CSS:
html, body {
width: 100%;
height: 100%;
}
body {
background: url(https://ununsplash.imgix.net/reserve/D9xlw7UxTBqQw5sLf8cJ_reef%20insp-72.jpg?q=75&fm=jpg&s=a46f72e373f7af2b3bba993f565e24be);
background-size: cover;
}
* {
margin: 0;
}
$color: #4C5C58;
$color-light: #5B6B67;
header {
position: absolute;
top: 27%;
left: calc(50% - 182px);
text-align: center;
-webkit-animation: anim2 1s ease-in-out 2.5s forwards;
}
#-webkit-keyframes anim1 {
100% {
transform: translateY(-12px);
opacity: 1;
}
}
#-webkit-keyframes anim2 {
100% {
transform: translateY(-70px);
}
}
#keyframes anim1 {
100% {
transform: translateY(-12px);
opacity: 1;
}
}
#keyframes anim2 {
100% {
transform: translateY(-70px);
}
}
h1 {
font-family: 'Open Sans', sans-serif;
font-size: 56px;
font-weight: 800;
color: $color;
opacity: 0;
-webkit-animation: anim1 1.5s ease-in-out forwards;
animation: anim1 1.5s ease-in-out forwards;
}
p {
font-family: 'Gentium Book Basic', serif;
font-style: italic;
font-size: 20px;
color: $color-light;
opacity: 0;
-webkit-animation: anim1 1.5s ease-in-out 0.3s forwards;
}
nav {
position: absolute;
left: calc(50% - 183px);
top: 45%;
}
a {
height: 40px;
width: auto;
background: none;
margin: 0 20px;
border: none;
cursor: pointer;
font-family: 'Gentium Book Basic', sans-serif;
font-weight: 500;
font-size: 15px;
color: $color-light;
transition: all 0.3s ease-in-out;
line-height: 50px;
opacity: 0;
display: inline-block;
}
a:hover {
border-bottom: double 3px $color-light;
}
img {
width: 150px;
position: absolute;
margin-left: 72px;
top: 38px;
}
nav p {
font-style: italic;
font-size: 14px;
position: absolute;
top: 80px;
left: 100px;
}
a:nth-of-type(1) {
-webkit-animation: anim1 1s ease-in-out 3s forwards;
animation: anim1 1s ease-in-out 3s forwards;
}
a:nth-of-type(2) {
-webkit-animation: anim1 1s ease-in-out 3.1s forwards;
animation: anim1 1s ease-in-out 3.1s forwards;
}
a:nth-of-type(3) {
-webkit-animation: anim1 1s ease-in-out 3.2s forwards;
animation: anim1 1s ease-in-out 3.2s forwards;
}
a:nth-of-type(4) {
-webkit-animation: anim1 1s ease-in-out 3.3s forwards;
animation: anim1 1s ease-in-out 3.3s forwards;
}
i am working on a Infinite Scrolling banner for a page but i am having issues with its output.
my html code is this: `e
<div class="header">
<img class="first" src="image-1.jpg" alt="" />
<img src="image2.jpg" alt="" />
<img src="image3.jpg" alt="" />
<img src="image4.jpg" alt="" />
<img src="image5.jpg" alt="" />
<img src="image6.jpg" alt="" />
<img src="image1.jpg" alt="" />
<img src="image2.jpg" alt="" />
<img src="image3.jpg" alt="" />
<img src="image4.jpg" alt="" />
</div>
</div>
and my CSS code is this:
`* {margin: 0; padding: 0;}
body {
background: url('background.jpg');
}
#container {
width: 1000px;
overflow: hidden;
margin: 50px auto;
background: white;
}
/*header*/
header {
width: 800px;
margin: 40px auto;
}
header h1 {
text-align: center;
font: 100 60px/1.5 Helvetica, Verdana, sans-serif;
}
header p {
font: 100 15px/1.5 Helvetica, Verdana, sans-serif;
text-align: justify;
}
/*photobanner*/
.photobanner {
height: 233px;
width: 3550px;
margin-bottom: 80px;
}
/*keyframe animations*/
.first {
-webkit-animation: bannermove 30s linear infinite;
-moz-animation: bannermove 30s linear infinite;
-ms-animation: bannermove 30s linear infinite;
-o-animation: bannermove 30s linear infinite;
animation: bannermove 30s linear infinite;
}
#keyframes "bannermove" {
0% {
margin-left: 0px;
}
100% {
margin-left: -2125px;
}
}
#-moz-keyframes bannermove {
0% {
margin-left: 0px;
}
100% {
margin-left: -2125px;
}
}
#-webkit-keyframes "bannermove" {
0% {
margin-left: 0px;
}
100% {
margin-left: -2125px;
}
}
#-ms-keyframes "bannermove" {
0% {
margin-left: 0px;
}
100% {
margin-left: -2125px;
}
}
#-o-keyframes "bannermove" {
0% {
margin-left: 0px;
}
100% {
margin-left: -2125px;
}
}
when i run the html file i see the banner scrolling but i can see the other pictures as well that is not in the banner at the time..
i should be only getting 3 pictures moving at one time and all other pics hidden but they are showing as well..please help..
<!DOCTYPE html>
<html>
<head>
<title>Photo banner</title>
<style>
* {margin: 0; padding: 0;}
body {
background-color: #FF0000;
}
#container {
width: 1000px;
overflow: hidden;
margin: 50px auto;
background: white;
}
/*header*/
header {
width: 800px;
margin: 40px auto;
}
header h1 {
text-align: center;
font: 100 60px/1.5 Helvetica, Verdana, sans-serif;
}
header p {
font: 100 15px/1.5 Helvetica, Verdana, sans-serif;
text-align: justify;
}
/*photobanner*/
.photobanner {
height: 233px;
width: 3550px;
margin-bottom: 80px;
}
/*keyframe animations*/
.first {
-webkit-animation: bannermove 30s linear infinite;
-moz-animation: bannermove 30s linear infinite;
-ms-animation: bannermove 30s linear infinite;
-o-animation: bannermove 30s linear infinite;
animation: bannermove 30s linear infinite;
}
#keyframes "bannermove" {
0% {
margin-left: 0px;
}
100% {
margin-left: -2125px;
}
}
#-moz-keyframes bannermove {
0% {
margin-left: 0px;
}
100% {
margin-left: -2125px;
}
}
#-webkit-keyframes "bannermove" {
0% {
margin-left: 0px;
}
100% {
margin-left: -2125px;
}
}
#-ms-keyframes "bannermove" {
0% {
margin-left: 0px;
}
100% {
margin-left: -2125px;
}
}
#-o-keyframes "bannermove" {
0% {
margin-left: 0px;
}
100% {
margin-left: -2125px;
}
}
.photobanner {
height: 233px;
width: 3550px;
margin-bottom: 80px;
}
.photobanner img {
-webkit-transition: all 0.5s ease;
-moz-transition: all 0.5s ease;
-o-transition: all 0.5s ease;
-ms-transition: all 0.5s ease;
transition: all 0.5s ease;
}
.photobanner img:hover {
-webkit-transform: scale(1.1);
-moz-transform: scale(1.1);
-o-transform: scale(1.1);
-ms-transform: scale(1.1);
transform: scale(1.1);
cursor: pointer;
-webkit-box-shadow: 0px 3px 5px rgba(0,0,0,0.2);
-moz-box-shadow: 0px 3px 5px rgba(0,0,0,0.2);
box-shadow: 0px 3px 5px rgba(0,0,0,0.2);
}
</style>
</head>
<body>
<div id="container">
<header>
<h1>Animated Photo Banner</h1>
<p>Lorem ipsum dolor...</p>
</header>
<!-- Each image is 350px by 233px -->
<div class="photobanner">
<img class="first" src="http://designshack.net/tutorialexamples/photobanner/image-1.jpg" alt="">
<img src="http://designshack.net/tutorialexamples/photobanner/image-2.jpg" alt="">
<img src="http://designshack.net/tutorialexamples/photobanner/image-3.jpg" alt="">
<img src="http://designshack.net/tutorialexamples/photobanner/image-4.jpg" alt="">
<img src="http://designshack.net/tutorialexamples/photobanner/image-5.jpg" alt="">
<img src="http://designshack.net/tutorialexamples/photobanner/image-6.jpg" alt="">
<img src="http://designshack.net/tutorialexamples/photobanner/image-1.jpg" alt="">
<img src="http://designshack.net/tutorialexamples/photobanner/image-2.jpg" alt="">
<img src="http://designshack.net/tutorialexamples/photobanner/image-3.jpg" alt="">
<img src="http://designshack.net/tutorialexamples/photobanner/image-4.jpg" alt="">
</div>
</div>
</body>
</div>