Hello developers, today in this blog, you'll learn how to create a Tab Gallery using HTML, CSS & JavaScript.
The Tab Gallery is simply an online gallery that displays some images as a tab. In this Tab Gallery, there are three images at the top and the space below to it. When you click on any of the particular top images, that particular image will get displayed at the center of the webpage as the main image.
You can also change the main image, by click the other images. The image which is displayed at the center has the crossbar at the top-right corner which is used to close the tab. JavaScript code is used to make the Tab Gallery work functionally.
The source code of this Tab Gallery using HTML, CSS & JavaScript is given below, if you want the source code of this program, you can copy it. You can use this Tab Gallery with your creativity and can take this project to the next level.
Tab Gallery using HTML, CSS & JavaScript [Source Code]
To make this website, you would like to make three files: an HTML file, a CSS file, and 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.
* {
box-sizing: border-box;
}
body {
margin: 0;
font-family: Arial;
background-color: #FBAB7E;
background-image: linear-gradient(62deg, #FBAB7E 0%, #F7CE68 100%);
}
.maincard{
background-color: #fff;
width: 90%;
margin: 10px auto;
padding:10px;
border-radius: 10px;
height:600px;
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
}
.column {
width: 25%;
padding: 10px;
}
.column img {
opacity: 1;
cursor: pointer;
width:25%;
height:150px;
border-radius: 10px;
box-shadow: rgba(50, 50, 93, 0.25) 0px 6px 12px -2px, rgba(0, 0, 0, 0.3) 0px 3px 7px -3px;
}
.column img:hover {
opacity: .9;
}
.row{
display: flex;
}
.container {
position: relative;
display: none;
margin: 5px auto;
width: 70%;
}
.container img {
width:100%;
height:400px;
border-radius: 10px;
box-shadow: rgba(50, 50, 93, 0.25) 0px 6px 12px -2px, rgba(0, 0, 0, 0.3) 0px 3px 7px -3px;
}
#imgtext {
position: absolute;
bottom: 15px;
left: 15px;
color: white;
font-size: 20px;
background-color: #202124;
padding:10px;
border-radius: 10px;
}
.closebtn {
position: absolute;
top: 10px;
right: 15px;
color: white;
font-size: 35px;
cursor: pointer;
}
.credit{
text-align: center;
color: #000;
font-weight: 900;
font-family: 'Trebuchet MS', 'Lucida Sans Unicode', 'Lucida Grande', 'Lucida Sans', Arial, sans-serif;
}
.credit a{
text-decoration: none;
color:#202124;
font-weight: bold;
}
function myFunction(imgs) {
var expandImg = document.getElementById("expandedImg");
var imgText = document.getElementById("imgtext");
expandImg.src = imgs.src;
imgText.innerHTML = imgs.alt;
expandImg.parentElement.style.display = "block";
}
Thank you for reading our blog. If you face any problem in creating this Tab Gallery using HTML & CSS, 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