HTML Example 3: Creating HTML Slider using CSS Animation

Creating HTML Slider by Using CSS Animation


By adding this style and div you can easily add an animated slider in HTML.


in this tutorial you will learn how to add Slider in your website by using simple CSS Animation, using @keyframes, animation-name, animation-duration, animation-iteration-count, animation-timing-function, animation-direction.

just added border-radius to add style in this slider.


Code

<style>
.myslider
{
border-radius:20px;
border:dotted;
width:700px;
height:400px;
background-image:url(https://4.bp.blogspot.com/-ha5Ee9sLNvE/WOtIJOB4iFI/AAAAAAAAAG4/ZCV_8a0DmkoN4kETmDC48pgU0f2_2HvSgCLcB/s1600/Allamaiqbal.jpg);
background-size:700px 400px;
animation-name:myfrm2;
animation-duration:20s;
animation-iteration-count:infinite;
animation-timing-function:ease-in;
animation-direction:alternate;
}
@keyframes myfrm2
{
0%
{
background-image:url(https://4.bp.blogspot.com/-ha5Ee9sLNvE/WOtIJOB4iFI/AAAAAAAAAG4/ZCV_8a0DmkoN4kETmDC48pgU0f2_2HvSgCLcB/s1600/Allamaiqbal.jpg);
}
20%
{
background-image:url(https://2.bp.blogspot.com/-dJMiwnuWSVg/WOtIGxJ-ARI/AAAAAAAAAG0/Fw2PlwP1EUcLohDKyG8ACA4TSMITnxHnACLcB/s1600/badshahimosque.jpg);
}
40%
{
background-image:url(https://2.bp.blogspot.com/--EqApyMEiKo/WOtIKwbXC2I/AAAAAAAAAG8/oEzWpiGz00E0HHwZgeyPoc98o4eeoYJOwCLcB/s1600/isl.jpg);
}
60%
{
background-image:url(https://3.bp.blogspot.com/-ZBSdBUj05ac/WOtILtJ6hbI/AAAAAAAAAHA/CVj2nmLplHEMO9i5uN43hQEFlbtQZZ9VQCLcB/s1600/khyberpass.jpg);
}
80%
{
background-image:url(https://2.bp.blogspot.com/--U6RpYmED8M/WOtIMp4p76I/AAAAAAAAAHE/ZIIw_lKEsK8h6ErAgQknjFzV7Vs0AckHQCLcB/s1600/quaideazam.jpg);
}
100%
{
background-image:url(https://4.bp.blogspot.com/-ha5Ee9sLNvE/WOtIJOB4iFI/AAAAAAAAAG4/ZCV_8a0DmkoN4kETmDC48pgU0f2_2HvSgCLcB/s1600/Allamaiqbal.jpg);
}
}
</style>
<br />
<div class="myslider">
</div>

Sample


HTML Example 3: Creating HTML Slider using CSS Animation HTML Example 3: Creating HTML Slider using CSS Animation Reviewed by Admin CZ on 2:05:00 PM Rating: 5

No comments

Recent