Testimonial Card Slider using HTML, CSS & JavaScript

Testimonial Card Slider using HTML, CSS & JavaScript

Hello developers, today in this blog, you'll learn how to create a Testimonial Card Slider using HTML, CSS & JavaScript.


The Slider is also called Carousel or Slideshow. The Slider may be the convenient way to display the changing or sliding cards one by one on the website. In this Testimonial Card Slider, the cards slide one by one by clicking on the slider button.

In this blog (Testimonial Card Slider) on the webpage, there is a card with a profile icon at the top center and a there is a quote inside the card, and a slider controls at the bottom side. These sliders are used to slide the preview cards. There are three cards with a quote and when you click on the slider button each card slides smoothly and shows another card.

In this card, the CSS border-radius property is used to make the corner of the card to be curved. The onclick function on the slider button is made by using JavaScript.

The source code of this Testimonial Card Slider using HTML, CSS & JavaScript is given below, if you want the source code of this program, you can copy it. You can use this Testimonial Card Slider code on your projects.

Testimonial Card Slider using HTML, CSS & JavaScript [Source Code]

To make this website, you would like to make three files: an HTML file, a CSS file & a JavaScript file. First, create an HTML file with the name of index.html and remember, you have to create a file with a .html extension.

<html> <head> <title>Testimonials slider || Learning Robo</title> <meta charset="UTF-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <meta http-equiv="X-UA-Compatible" content="ie=edge" /> <link rel="stylesheet" href="style.css"> </head> <body> <div class="container"> <div class="veiw-box"> <div id="testimonials"> <div class="user"> <img src="https://cdn.pixabay.com/photo/2018/11/13/21/43/instagram-3814049__340.png" alt=""> <p>Many people feel that there is a limited amount of abundance, wealth, or chance to succeed in life. Furthermore, there is a solid belief that if one person succeeds, another must fail.</p> <h3>Learning Robo</h3> <div class="credit">Made with <span style="color:tomato">❤</span> by <a href="https://www.learningrobo.com/">Learning Robo</a></div> </div> <div class="user space"> <img src="https://cdn.pixabay.com/photo/2018/11/13/21/43/instagram-3814049__340.png" alt=""> <p>Many people feel that there is a limited amount of abundance, wealth, or chance to succeed in life. Furthermore, there is a solid belief that if one person succeeds, another must fail.</p> <h3>Learning Robo</h3> <div class="credit">Made with <span style="color:tomato">❤</span> by <a href="https://www.learningrobo.com/">Learning Robo</a></div> </div> <div class="user"> <img src="https://cdn.pixabay.com/photo/2018/11/13/21/43/instagram-3814049__340.png" alt=""> <p>Many people feel that there is a limited amount of abundance, wealth, or chance to succeed in life. Furthermore, there is a solid belief that if one person succeeds, another must fail.</p> <h3>Learning Robo</h3> <div class="credit">Made with <span style="color:tomato">❤</span> by <a href="https://www.learningrobo.com/">Learning Robo</a></div> </div> </div> <div class="controls"> <span id="control1"></span> <span id="control2" class="active"></span> <span id="control3"></span> </div> </div> </div> <script src="script.js"></script> </body> </html>
CSS provides style to an HTML page. To make the page attractive create a CSS file with the name style.css and remember that you have to make a file with a .css extension.


* {
    padding: 0;
    margin: 0;
    font-family: sans-serif;
}

.container{
    width: 100%;
    height: 100vh;
    background: #12192c;
    position: relative;
}
.veiw-box{
    width: 900px;
    height: 500px;
    border-radius: 220px;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%,-50%);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;    
}
#testimonials{
    display: flex;
    transition: 0.5s;
}
.user{
    width: 800px;
    text-align: center;
    padding: 20px 70px;
    box-sizing: border-box;
    background: #12192c;
    border-radius: 200px;
    box-shadow: 0 10px 20px -5px #00000061;
    position: relative;
    border: 10px solid #cbb4f5;
}

.space{
    margin: 0 70px;
}
.user img{
    width: 120px;
    border-radius: 50%;
    border: 10px solid #202124;
    position: absolute;
    top: -80px;
    left: 50%;
    transform: translateX(-50%);
}
.user p{
    font-size: 22px;
    color: #cbb4f5;
    line-height: 32px;
    margin: 60px 0 30px;
}
.user p::before{
    content: '\201C';
    font-size: 120px;
    height: 0;
    display: inline-block;
    vertical-align: -57;
    margin-right: 10px;
}
.user p::after{
    content: '\201D';
    font-size: 120px;
    height: 0;
    display: inline-block;
    vertical-align: -70;
    margin-left: 10px;
}
.user h3{
    font-size: 26px;
    color: #cbb4f5;
}
.controls{
    display: flex;
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
}
.controls span{
    width: 15px;
    height: 15px;
    background: #cbb4f5;
    border-radius: 15px;
    margin: 0 5px;
    cursor: pointer;
    transition: 0.5s;
}
.active{
    width: 45px !important;
}
.credit{
    text-align: center;
    color: #cbb4f5;
    font-family: 'Trebuchet MS', 'Lucida Sans Unicode', 'Lucida Grande', 'Lucida Sans', Arial, sans-serif;
}

.credit a{
    text-decoration: none;
    color:#fff;
    font-weight: bold;
} 
JavaScript makes the page work functionally. At last, create a JavaScript file with the name of script.js and remember that you have got need to make a file with a .js extension.


var testimonials = document.getElementById('testimonials');
var control1 = document.getElementById('control1');
var control2 = document.getElementById('control2');
var control3 = document.getElementById('control3');


control1.onclick=function(){
    testimonials.style.transform = "translateX(870px)";
    control1.classList.add("active");
    control2.classList.remove("active");
    control3.classList.remove("active");
}

control2.onclick=function(){
    testimonials.style.transform = "translateX(0px)";
    control1.classList.remove("active");
    control2.classList.add("active");
    control3.classList.remove("active");
}

control3.onclick=function(){
    testimonials.style.transform = "translateX(-870px)";
    control1.classList.remove("active");
    control2.classList.remove("active");
    control3.classList.add("active");
}
We hope you would like this Testimonial Card Slider using HTML, CSS & JavaScript.

Thank you for reading our blog. If you face any problem in creating this Testimonial Card Slider using HTML, CSS & JavaScript, then contact us or comment us. We’ll try to provide a solution to your problem as soon as possible.

Thank you
Learning robo team

Post a Comment

Thank you
Learning robo team

Post a Comment (0)

Previous Post Next Post
Learning Robo says...
code copied
Welcome