K
K
Kircha2018-03-03 01:01:56
css
Kircha, 2018-03-03 01:01:56

How to preload photos in my code?

I hope for your help.
This code will smoothly change the background to the next one.

<!DOCTYPE html>
<html><head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
.body_slides{
  list-style:none;
  margin:0;
  padding:0;
  z-index:-2; 
  background:none;}
.body_slides,
.body_slides:after{
    position: fixed;
  width:100%;
  height:100%;
  top:0px;
  left:0px;}

@-webkit-keyframes anim_slides {
0% {opacity:0;}
1% {opacity:1;}
15% {opacity:1;}
20% {opacity:0;}
88% {opacity:0;}
}
@-moz-keyframes anim_slides {
0% {opacity:0;}
1% {opacity:1;}
15% {opacity:1;}
20% {opacity:0;}
88% {opacity:0;}
}
.body_slides li{
    width:100%;
  height:100%;
  position:absolute;
  top:0;
  left:0;
    background-size:cover;
    background-repeat:none;
  opacity:0;
    -webkit-animation: anim_slides 21s linear infinite 0s;
    -moz-animation: anim_slides 21s linear infinite 0s;
    -o-animation: anim_slides 21s linear infinite 0s;
    -ms-animation: anim_slides 21s linear infinite 0s;
    animation: anim_slides 21s linear infinite 0s;
}
  
.body_slides li:nth-child(1){
background-image: url(images/1.jpg) 
}
.body_slides li:nth-child(2){
-webkit-animation-delay: 1.0s;
-moz-animation-delay: 1.0s;
background-image: url(images/2.jpg) 
}
.body_slides li:nth-child(3){
-webkit-animation-delay: 2.0s;
-moz-animation-delay: 2.0s;
background-image: url(images/3.jpg) 
}
.body_slides li:nth-child(4){
-webkit-animation-delay: 3.0s;
-moz-animation-delay: 3.0s;
background-image: url(images/4.jpg) 
}
.body_slides li:nth-child(5){
-webkit-animation-delay: 4.0s;
-moz-animation-delay: 4.0s;
background-image: url(images/5.jpg) 
}
.body_slides li:nth-child(6){
-webkit-animation-delay: 5.0s;
-moz-animation-delay: 5.0s;
background-image: url(images/6.jpg) 
}
.body_slides li:nth-child(7){
-webkit-animation-delay: 6.0s;
-moz-animation-delay: 6.0s;
background-image: url(images/7.jpg) 
}
#fixedbutton {
    position: fixed;
    bottom: 5px;
    right: 5px; 
}
body {
    background: url('images/7.jpg') no-repeat center center fixed;
    -webkit-background-size: cover;
    -moz-background-size: cover;
    -o-background-size: cover;
    background-size: cover;
  }
</style>

</head>
<body id="body">

        <ul class="body_slides">
            <li></li>
            <li></li>
            <li></li>
      <li></li>
      <li></li>
      <li></li>
      <li></li>

        </ul>
    <a href="../index.html"><img src="images/upbutton.jpg" id="fixedbutton"></a>
</body>
</html>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
F
FODD, 2018-03-04
@Kircha

Place images with a tag, not a background.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question