-
-
Save ertankayalar/4e2ef519e4a9a435772a53c4da0bb27c to your computer and use it in GitHub Desktop.
Auto Sliding Background images in html and css
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<title></title> | |
<link rel="stylesheet" type="text/css" href="style.css"> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1"> | |
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css"> | |
<link href="https://fonts.googleapis.com/css?family=Poppins&display=swap" rel="stylesheet"> | |
</head> | |
<body> | |
<div class="header"> | |
<!-- Sliding Background --> | |
<div class="slider"> | |
<figure> | |
<div class="slide"> | |
<img src="s1.jpeg" alt="1"> | |
</div> | |
<div class="slide"> | |
<img src="s2.jpeg" alt="2"> | |
</div> | |
<div class="slide"> | |
<img src="s3.jpeg" alt="3"> | |
</div> | |
<div class="slide"> | |
<img src="s4.jpeg" alt="4"> | |
</div> | |
<div class="slide"> | |
<img src="s5.jpeg" alt="5"> | |
</div> | |
<div class="slide"> | |
<img src="s6.jpeg" alt="6"> | |
</div> | |
</figure> | |
</div> | |
<!-- /Sliding Background --> | |
</div> | |
</body> | |
</html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.header{ | |
width: 100%; | |
height: 100vh; | |
background-color: orange; | |
} | |
/* Sliding Background */ | |
.slider{ | |
overflow: hidden; | |
width: 100%; | |
height: 100vh; | |
} | |
.slider figure div{ | |
float: left; | |
width: 100%; | |
} | |
.slider figure img{ | |
width: 100%; | |
height: 100vh; | |
background-size: cover; | |
background-position: center; | |
background-repeat: no-repeat; | |
float: left; | |
} | |
.slider figure{ | |
position: relative; | |
width: 500% | |
margin: 0; | |
animation: animate 20s infinite; | |
} | |
.slide p{ | |
position: fixed; | |
color: #fff; | |
font-size: 70px; | |
text-align: center; | |
padding-top: 250px; | |
width: 100%; | |
height: 100vh; | |
} | |
@keyframes animate{ | |
0%{left:0;} | |
10%{left:0;} | |
12%{left:-100%;} | |
22%{left:-100%;} | |
24%{left:-200%;} | |
34%{left:-200%;} | |
36%{left:-300%;} | |
46%{left:-300%;} | |
48%{left:-400%;} | |
58%{left:-400%;} | |
60%{left:-300%;} | |
70%{left:-300%;} | |
72%{left:-200%;} | |
82%{left:-200%;} | |
84%{left:-100%;} | |
94%{left:-100%;} | |
96%{left:-0;} | |
} | |
/* /Sliding Background */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment