In the world of web development, image sliders have become a popular way to showcase multiple images or content in a visually appealing manner. This article aims to provide you with a comprehensive guide on how to create an image slider using HTML. Whether you’re a beginner or an experienced developer, this guide will walk you through the process step-by-step, ensuring that you understand the concepts and can implement an image slider effectively.

Section 1: Understanding the Basics of HTML
In this section, we will briefly explain the fundamental concepts of HTML, ensuring that readers have a solid foundation before diving into the image slider creation process. We will cover HTML tags, attributes, and the overall structure of an HTML document.

Section 2: Setting Up the HTML Structure for the Image Slider
Here, we will guide you through the process of setting up the HTML structure for the image slider. This includes creating the necessary HTML elements, such as the container, slides, and navigation buttons, and logically organizing them.

Section 3: Styling the Image Slider with CSS
In this section, we will explore how CSS can be used to style the image slider and make it visually appealing. We’ll cover important styling properties, such as dimensions, positioning, transitions, and effects, allowing you to customize the appearance of your image slider according to your preferences.

Section 4: Adding Functionality with JavaScript
To make the image slider interactive, JavaScript comes into play. In this section, we will discuss how JavaScript can be used to add functionality to the image slider, such as automatic sliding, navigation controls, and responsive behavior for different devices.


Section 5: Testing and Troubleshooting
Once you have implemented the image slider, it’s crucial to test its functionality and address any potential issues. In this section, we will provide tips on how to test your image slider across different browsers and devices, as well as common troubleshooting techniques to overcome any challenges you may encounter.
Conclusion:


By following this comprehensive guide, you should now have a solid understanding of how to create an image slider using HTML. We have covered the basics of HTML, the setup of the HTML structure, styling with CSS, adding functionality with JavaScript, and testing the image slider. With this knowledge, you can now confidently create visually appealing image sliders for your websites, enhancing the user experience and showcasing your content effectively.

HTML

  1. Create a Folder:
    • You can create a new folder anywhere you’d like on your computer. Could you give it a name of your choice? For example, let’s call it “my website.”
  2. Inside the Folder:
    • Open the newly created folder (“my-website” in our example).
    • Inside this folder, create the following files:
  3. Create an index.html File:
    • Right-click inside the folder and choose New Text Document.
    • Rename the newly created text document to “index.html” (make sure to remove the “.txt” extension).
    • Open the “index.html” file using a text editor (such as Notepad or Visual Studio Code).
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.2/css/all.min.css" />
    <link rel="stylesheet" href="./style.css">
    <title>team animated</title>
</head>

<body>
    <div class="container">
        <div class="icon">
            <div class="imgBx active" style="--i:1;" data-id="content1">
                <img src="https://images.hdqwalls.com/wallpapers/goku-ultimate-technique-mg.jpg" alt="">
            </div>
            <div class="imgBx" style="--i:2;" data-id="content2">
                <img src="https://images.hdqwalls.com/wallpapers/vegeta-the-saiyan-prince-4k-yl.jpg" alt="">
            </div>
            <div class="imgBx" style="--i:3;" data-id="content3">
                <img src="https://w0.peakpx.com/wallpaper/457/669/HD-wallpaper-jiren-anime-dragon-ba-dragon-ball-super-goku.jpg"
                    alt="">
            </div>
            <div class="imgBx" style="--i:4;" data-id="content4">
                <img src="https://w0.peakpx.com/wallpaper/905/185/HD-wallpaper-frieza-anime-ball-dragon-goku-golden-super-vegeta.jpg"
                    alt="">
            </div>
            <div class="imgBx" style="--i:5;" data-id="content5">
                <img src="https://w0.peakpx.com/wallpaper/825/913/HD-wallpaper-broly-ball-dragon-super.jpg" alt="">
            </div>
            <div class="imgBx" style="--i:6;" data-id="content6">
                <img src="https://w0.peakpx.com/wallpaper/25/277/HD-wallpaper-goku-black-rose-dragon-ball-legends-goku-black-super-saiyan.jpg"
                    alt="">
            </div>
            <div class="imgBx" style="--i:7;" data-id="content7">
                <img src="https://w0.peakpx.com/wallpaper/707/534/HD-wallpaper-lord-beerus-dragon-ball-dragon-ball-legends-god-of-destruction.jpg"
                    alt="">
            </div>
            <div class="imgBx" style="--i:8;" data-id="content8">
                <img src="https://w0.peakpx.com/wallpaper/409/730/HD-wallpaper-the-ultimate-fusion-dbz-dragon-ball-dragon-ball-super-dragon-ball-z-gogeta.jpg"
                    alt="">
            </div>
        </div>
        <div class="content">
            <div class="contentBx active" id="content1">
                <div class="card">
                    <div class="imgBx">
                        <img src="https://images.hdqwalls.com/wallpapers/goku-ultimate-technique-mg.jpg" alt="">
                    </div>
                    <div class="textBx">
                        <h2>Goku<br><span></span></h2>
                        <ul class="sci">
                            <li><a href="#"><i class="fa-brands fa-instagram"></i></a></li>
                            <li><a href="#"><i class="fa-brands fa-telegram"></i></a></li>
                            <li><a href="#"><i class="fa-brands fa-github"></i></a></li>
                            <li><a href="#"><i class="fa-brands fa-youtube"></i></a></li>
                        </ul>
                    </div>
                </div>
            </div>

            <div class="contentBx" id="content2">
                <div class="card">
                    <div class="imgBx">
                        <img src="https://images.hdqwalls.com/wallpapers/vegeta-the-saiyan-prince-4k-yl.jpg" alt="">
                    </div>
                    <div class="textBx">
                        <h2>vegetas<br></h2>
                        <ul class="sci">
                            <li><a href="#"><i class="fa-brands fa-instagram"></i></a></li>
                            <li><a href="#"><i class="fa-brands fa-telegram"></i></a></li>
                            <li><a href="#"><i class="fa-brands fa-github"></i></a></li>
                            <li><a href="#"><i class="fa-brands fa-youtube"></i></a></li>
                        </ul>
                    </div>
                </div>
            </div>

            <div class="contentBx" id="content3">
                <div class="card">
                    <div class="imgBx">
                        <img src="https://w0.peakpx.com/wallpaper/457/669/HD-wallpaper-jiren-anime-dragon-ba-dragon-ball-super-goku.jpg"
                            alt="">
                    </div>
                    <div class="textBx">
                        <h2>jirens<br></h2>
                        <ul class="sci">
                            <li><a href="#"><i class="fa-brands fa-instagram"></i></a></li>
                            <li><a href="#"><i class="fa-brands fa-telegram"></i></a></li>
                            <li><a href="#"><i class="fa-brands fa-github"></i></a></li>
                            <li><a href="#"><i class="fa-brands fa-youtube"></i></a></li>
                        </ul>
                    </div>
                </div>
            </div>

            <div class="contentBx" id="content4">
                <div class="card">
                    <div class="imgBx">
                        <img src="https://w0.peakpx.com/wallpaper/905/185/HD-wallpaper-frieza-anime-ball-dragon-goku-golden-super-vegeta.jpg"
                            alt="">
                    </div>
                    <div class="textBx">
                        <h2>frieza<br></h2>
                        <ul class="sci">
                            <li><a href="#"><i class="fa-brands fa-instagram"></i></a></li>
                            <li><a href="#"><i class="fa-brands fa-telegram"></i></a></li>
                            <li><a href="#"><i class="fa-brands fa-github"></i></a></li>
                            <li><a href="#"><i class="fa-brands fa-youtube"></i></a></li>
                        </ul>
                    </div>
                </div>
            </div>

            <div class="contentBx" id="content5">
                <div class="card">
                    <div class="imgBx">
                        <img src="https://w0.peakpx.com/wallpaper/825/913/HD-wallpaper-broly-ball-dragon-super.jpg"
                            alt="">
                    </div>
                    <div class="textBx">
                        <h2>broly<br></h2>
                        <ul class="sci">
                            <li><a href="#"><i class="fa-brands fa-instagram"></i></a></li>
                            <li><a href="#"><i class="fa-brands fa-telegram"></i></a></li>
                            <li><a href="#"><i class="fa-brands fa-github"></i></a></li>
                            <li><a href="#"><i class="fa-brands fa-youtube"></i></a></li>
                        </ul>
                    </div>
                </div>
            </div>

            <div class="contentBx" id="content6">
                <div class="card">
                    <div class="imgBx">
                        <img src="https://w0.peakpx.com/wallpaper/25/277/HD-wallpaper-goku-black-rose-dragon-ball-legends-goku-black-super-saiyan.jpg"
                            alt="">
                    </div>
                    <div class="textBx">
                        <h2>block goku<br></h2>
                        <ul class="sci">
                            <li><a href="#"><i class="fa-brands fa-instagram"></i></a></li>
                            <li><a href="#"><i class="fa-brands fa-telegram"></i></a></li>
                            <li><a href="#"><i class="fa-brands fa-github"></i></a></li>
                            <li><a href="#"><i class="fa-brands fa-youtube"></i></a></li>
                        </ul>
                    </div>
                </div>
            </div>

            <div class="contentBx" id="content7">
                <div class="card">
                    <div class="imgBx">
                        <img src="https://w0.peakpx.com/wallpaper/707/534/HD-wallpaper-lord-beerus-dragon-ball-dragon-ball-legends-god-of-destruction.jpg"
                            alt="">
                    </div>
                    <div class="textBx">
                        <h2>Lord Beerus<br></h2>
                        <ul class="sci">
                            <li><a href="#"><i class="fa-brands fa-instagram"></i></a></li>
                            <li><a href="#"><i class="fa-brands fa-telegram"></i></a></li>
                            <li><a href="#"><i class="fa-brands fa-github"></i></a></li>
                            <li><a href="#"><i class="fa-brands fa-youtube"></i></a></li>
                        </ul>
                    </div>
                </div>
            </div>

            <div class="contentBx" id="content8">
                <div class="card">
                    <div class="imgBx">
                        <img src="https://w0.peakpx.com/wallpaper/409/730/HD-wallpaper-the-ultimate-fusion-dbz-dragon-ball-dragon-ball-super-dragon-ball-z-gogeta.jpg"
                            alt="">
                    </div>
                    <div class="textBx">
                        <h2>Abhishek mishra<br></h2>
                        <ul class="sci">
                            <li><a href="#"><i class="fa-brands fa-instagram"></i></a></li>
                            <li><a href="#"><i class="fa-brands fa-telegram"></i></a></li>
                            <li><a href="#"><i class="fa-brands fa-github"></i></a></li>
                            <li><a href="#"><i class="fa-brands fa-youtube"></i></a></li>
                        </ul>
                    </div>
                </div>
            </div>


        </div>
    </div>
</body>

</html>

CSS

2. Create a style.css File:

  • Right-click inside the folder again and choose New Text Document.
  • Rename the newly created text document to style.css (remove the “.txt” extension).
  • Open the style.css file using a text editor.
    <style>
        @import url("https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap");

        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            font-family: "Poppins", sans-serif;
        }

        body {
            display: flex;
            justify-content: center;
            align-items: center;
            min-height: 100vh;
            background: #1b1817;
        }

        .container {
            position: relative;
            width: 600px;
            height: 600px;
            border: 1px solid #f5f5f5;
            border-radius: 50%;
        }

        .container .icon {
            position: relative;
            width: 100%;
            height: 100%;
            left: -50%;
            display: flex;
            justify-content: center;
            align-items: center;
            cursor: pointer;
        }

        .container .icon .imgBx {
            position: absolute;
            width: 80px;
            height: 80px;
            border-radius: 50%;
            transition: 0.5s;
            border: 1px solid #fff;
            box-shadow: 0 0 0 4px #222, 0 0 0 6px #fff;
            transform: rotate(calc(360deg / 8 * var(--i)));
            transform-origin: 340px;
            z-index: 100;
            overflow: hidden;
        }

        .container .icon .imgBx:hover {
            margin-top: -10px;
        }

        .container .icon .imgBx.active {
            box-shadow: 0 0 0 4px #222, 0 0 10px 10px #ff611d;
        }

        .container .icon .imgBx img {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            border-radius: 50%;
            object-fit: cover;
            transform: rotate(calc(-360deg / 8 * var(--i)));
            transition: 0.5s;
            filter: grayscale(1);
        }

        .container .icon .imgBx.active img {
            filter: grayscale(0);
        }

        .content {
            position: absolute;
            inset: 0;
            overflow: hidden;
            display: flex;
            justify-content: center;
            align-items: center;
        }

        .content:before {
            content: "";
            position: absolute;
            inset: 70px;
            border: 4px solid transparent;
            border-left: 15px solid #fe650c;
            border-right: 15px solid #fff;
            border-radius: 50%;
            animation: anim1 5s linear infinite;
            z-index: 1;
            pointer-events: none;
        }

        @keyframes anim1 {
            0% {
                rotate: 0deg;
            }

            100% {
                rotate: 360deg;
            }
        }

        .content:after {
            content: "";
            position: absolute;
            inset: 125px;
            border: 4px solid transparent;
            border-top: 28px solid #02e919;
            border-bottom: 18px solid #f1faee;
            border-radius: 50%;
            animation: anim2 2.6s linear infinite;
            z-index: 1;
            pointer-events: none;
        }

        @keyframes anim2 {
            0% {
                rotate: 360deg;
            }

            100% {
                rotate: 0deg;
            }
        }

        .contentBx {
            position: absolute;
            transform: scale(0);
            transition: 0.5s;
            opacity: 0;
            display: flex;
            justify-content: center;
            align-items: center;
        }

        .contentBx.active {
            transform: scale(1);
            opacity: 1;
            transition-delay: 0.5s;
        }

        .contentBx .card {
            position: relative;
            display: flex;
            justify-content: center;
            align-items: center;
            flex-direction: column;
            grid-auto-flow: 15px;
        }

        .contentBx .card .imgBx {
            position: relative;
            width: 150px;
            height: 150px;
            border-radius: 10px;
            overflow: hidden;
        }

        .contentBx .card .imgBx img {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            object-fit: cover;
        }

        .contentBx .card .textBx {
            display: flex;
            justify-content: center;
            align-items: center;
            flex-direction: column;
        }

        .contentBx .card .textBx h2 {
            margin-top: 10px;
            position: relative;
            font-size: 1.25rem;
            font-weight: 600;
            color: #fff;
            line-height: 1em;
            text-transform: uppercase;
            text-align: center;
        }

        .contentBx .card .textBx h2 span {
            font-size: 0.65em;
            color: #fff;
            font-weight: 500;
            letter-spacing: 0.1em;
        }

        .contentBx .card .textBx .sci {
            position: relative;
            display: flex;
            gap: 7px;
            margin-top: 10px;
        }

        .contentBx .card .textBx .sci li {
            list-style: none;
        }

        .contentBx .card .textBx .sci li a {
            position: relative;
            width: 30px;
            height: 30px;
            display: flex;
            justify-content: center;
            align-items: center;
            text-decoration: none;
            background: #444;
            color: #fff;
            text-decoration: none;
            border-radius: 5px;
            transition: 0.5s;
        }

        .contentBx .card .textBx .sci li a:hover {
            background: #2196f3;
        }
    </style>

JavaScript

3. Create a script.js File:

  • Right-click inside the folder once more and choose “New” > “Text Document.”
  • Rename the newly created text document to “script.js” (remove the “.txt” extension).
  • Open the “script.js” file using a text editor.
    <script>
        let imgBx = document.querySelectorAll('.imgBx')
        let contentBx = document.querySelectorAll('.contentBx')

        for (let i = 0; i < imgBx.length; i++) {
            imgBx[i].addEventListener('mouseover', function () {
                for (let i = 0; i < contentBx.length; i++) {
                    contentBx[i].className = 'contentBx';
                }
                document.getElementById(this.dataset.id).className = 'contentBx active';


                for (let i = 0; i < imgBx.length; i++) {
                    imgBx[i].className = 'imgBx';
                }
                this.className = 'imgBx active';
            })
        }
    </script>

And in case you guys are getting any errors then make sure to solve them, I created a folder for you people within the ZIP file |go and download it below| and have this downloaded so special thanks from James bush. you will get the link.

Author

Telegram Group Join Now
WhatsApp Group Join Now
Instagram Group Join Now

By aczone

Leave a Reply

Your email address will not be published. Required fields are marked *