Coder Wrap provides free to use snippets Coder Wrap provides free to use snippets

Back to Gallery
Preview Source Code
Download
HTML
CSS
/**Typeo CSS Start**/
@import url('https://fonts.googleapis.com/css2?family=Rubik:ital,wght@0,400;0,500;0,700;0,800;1,300;1,400;1,500;1,600;1,700&display=swap');

* {
	box-sizing: border-box;
}

body {
	margin: 0px;
	background-color: #fff;
}

img {
	max-width: 100%;
}

/**Typeo CSS End**/
.gallery1-scn, .gallery1-scn * {
	--page-width: 1330px;
	--base-fm: 'Rubik', sans-serif;
	--title-size: 40px;
	--base-size: 20px;
	--white-clr: #ffffff;
	--theme-clr: #1ea69a;
	--bg-clr: #F9F6F2;
}

.page-width {
	max-width: var(--page-width);
	padding: 0 15px;
	margin: auto;
	width: 100%;
}

.gallery1-scn {
	background: rgb(48, 158, 100);
	background: linear-gradient(49deg, rgba(48, 158, 100, 1) 0%, rgba(5, 130, 186, 1) 47%, rgba(2, 108, 181, 1) 100%);
	width: 100%;
	padding: 40px 0px;
	font-family: var(--base-fm);
	font-size: var(--base-size);
	display: flex;
	flex-flow: row wrap;
	align-items: center;
	text-align: center;
}

.gallery1-scn h2 {
	font-size: var(--title-size);
	color: var(--white-clr);
	margin: 0px;
}

.gallery-list {
	display: flex;
	flex-flow: row wrap;
	width: calc(100% + 30px);
	margin-left: -15px;
	margin-top: 20px;
}

.gallery-list .gallery-item {
	width: calc(33.33% - 30px);
	margin: 15px;
	cursor: pointer;
	overflow: hidden;
}

.gallery-list .gallery-item img {
	display: block;
	transition: 0.5s all;
	width: 100%;
	pointer-events: none;
}

.gallery-list .gallery-item:hover img {
	transform: scale(1.1);
}

/**Gallery Popup**/
.gModel-overlay {
	width: 100%;
	height: 100%;
	position: fixed;
	left: 0px;
	top: 0px;
	background-color: rgba(0, 0, 0, 0.5);
}

.gallerymodel {
	pointer-events: none;
	opacity: 0;
	transition: 0.5s all;
}

.gallerymodelshow {
	pointer-events: auto;
	opacity: 1;
}

.gallerymodel .gallery-list {
	margin: 0px;
	width: 100%;
	overflow: hidden;
	max-width: 1000px;
	width: 100%;
	margin: auto;
	position: fixed;
	left: 0px;
	right: 0px;
	top: 50%;
	transform: translateY(-50%);
}

.gallerymodel .gallery-list .gallery-item {
	width: 100%;
	margin: 0px;
	display: none;
}

.gallerymodel .gallery-list .gallery-item.active {
	display: block;
}

.gModel-close {
	color: #fff;
	z-index: 99;
	position: fixed;
	right: 15px;
	top: 15px;
	font-weight: 300;
	font-size: 30px;
	cursor: pointer;
}

.slideArrows {
	position: fixed;
	z-index: 999;
	color: #fff;
	max-width: 1050px;
	width: 100%;
	top: 50%;
	left: 0px;
	right: 0px;
	margin: auto;
	display: flex;
	flex-flow: row wrap;
	justify-content: space-between;
	transform: translateY(-50%);
}

.slideArrows #slidePrev, .slideArrows #slideNext {
	cursor: pointer;
}

.slideArrows span:before {
	content: '';
	position: absolute;
	width: 20px;
	height: 20px;
	border-left: #fff 3px solid;
	border-bottom: #fff 3px solid;
	top: 50%;
	margin-left: -5px;
	transform: rotate(45deg);
	margin-top: -10px;
}

.slideArrows #slideNext:before {
	margin-left: -17px;
	transform: rotate(225deg);
}

@media(max-width:1100px) {
	.gallerymodel .gallery-list {
		width: calc(100% - 30px);
	}

	.slideArrows {
		width: calc(100% - 70px);
	}

}

@media(max-width:767px) {
	.gallery1-scn {
		padding: 20px 0px;
	}

	.gallery1-scn h2 {
		font-size: calc(var(--title-size) - 10px);
	}

	.gallery-list {
		width: calc(100% + 10px);
		margin-left: -5px;
		margin-top: 10px;
	}

	.gallery-list .gallery-item {
		width: calc(33.33% - 10px);
		margin: 5px;
	}

	.gallerymodel .gallery-list {
		width: calc(100% - 10px);
	}

	.slideArrows {
		width: calc(100% - 40px);
	}

	.gModel-close {
		font-size: 24px;
	}

	.slideArrows span:before {
		width: 14px;
		height: 14px;
	}

}
JS
 //Append Model Popup Code
 const div = document.createElement("div");
 const gmodelClass = div.setAttribute("class", "gallerymodel");
 document.querySelector('.gallery1-scn').appendChild(div);
 document.querySelector('.gallerymodel').innerHTML = "🗙 
"; //.appendChild(div); document.querySelector(".gallery-list .gallery-item:first-child").classList.add('active'); const galleryList = document.querySelector(".gallery-list"); const clonedGallery = galleryList.cloneNode(true); document.querySelector(".gallerymodel").appendChild(clonedGallery); let galleryItems = document.querySelectorAll('.gallery-list .gallery-item'); galleryItems.forEach(function(item) { item.addEventListener('click', function(e) { galleryItems.forEach(function(item) { item.classList.remove('active'); }); e.target.classList.add('active'); }); }); /**Model Click Start**/ //Slider Coder Here function Slider(startIndex) { let slideItems = document.querySelectorAll('.gallerymodel .gallery-list .gallery-item'); let i = startIndex; function sliderItemNext() { i++; if (slideItems.length - 1 < i) { i = 0; } slideItems.forEach(item => { item.classList.remove('active'); }); slideItems[i].classList.add('active'); } function sliderItemPrev() { i--; if (i < 0) { i = slideItems.length - 1; } slideItems.forEach(item => { item.classList.remove('active'); }); slideItems[i].classList.add('active'); } document.getElementById("slideNext").addEventListener("click", function() { sliderItemNext(); }); document.getElementById("slidePrev").addEventListener("click", function() { sliderItemPrev(); }); slideItems.forEach((item, index) => { if (item.classList.contains('active')) { i = index; } }); slideItems[i].classList.add('active'); } //Slider Coder Here let items = document.querySelectorAll('.gallery-list .gallery-item[data-gallery]'); items.forEach(function(item) { item.addEventListener('click', function(e) { let gallery = e.target.getAttribute('data-gallery'); let listItems = document.querySelectorAll('.gallery-list .gallery-item[data-gallery="' + gallery + '"]'); listItems.forEach(function(listItem) { listItem.classList.add('active'); }); document.querySelector('.gallerymodel').classList.add('gallerymodelshow'); Slider() }); }); /**Model Click Start**/ //Model Close document.querySelector('.gModel-close').addEventListener('click', function(e) { document.querySelector('.gallerymodel').classList.remove('gallerymodelshow'); });

Related Snippets

Leave a comment

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