Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <header>
	<div class="hero"></div>
</header>
<div class="container">
	<div id="profileDetails">
		<div class="logo">
			<img src="https://cdn1.iconfinder.com/data/icons/social-messaging-productivity-1-1/128/gender-male2-512.png" alt="profileicon">
		</div>
		<div class="profile">
			<h1>Bio:</h1>
			<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. A consequatur iste quod facilis deleniti aperiam voluptate doloribus molestiae.</p>
			<div class="socialLinks">
				<a href="#"><i class="fa fa-twitter-square" aria-hidden="true"></i>
</a>
				<a href="#"><i class="fa fa-pinterest-square" aria-hidden="true"></i>
</a>
				<a href="#"><i class="fa fa-facebook-official" aria-hidden="true"></i></a>
			</div>
		</div>
	</div>
	<div class="contentContainer">
		<header class="tabs">
			<div class="tab">All</div>
			<div class="tab">Animals</div>
			<div class="tab">Landscapes</div>
			<div class="tab">Buildings</div>
		</header>
		<div class="tabBorder"></div>
		<main>
			<div class="gallery">
				<figure data-category="landscape">
				  <img src="https://images.unsplash.com/photo-1413752567787-baa02dde3c65?ixlib=rb-0.3.5&ixid=eyJhcHBfaWQiOjEyMDd9&s=00dab0342c1b6498228d16e4a7d82ad3&w=1000&q=80" alt="landscape">
				  <figcaption>Landscape</figcaption>
				</figure>
				
				<figure data-category="landscape" >
				  <img src="https://d2v9y0dukr6mq2.cloudfront.net/video/thumbnail/Wj2ycoF/beautiful-tropical-beach-scene-with-tilting-up-camera_vh_zkr-_e__F0000.png" alt="landscape">
				  <figcaption>A beautiful beach and blue sea</figcaption>
				</figure>
				
				<figure data-category="building">
				  <img src="http://www.diamzon.com/wp-content/uploads/2016/11/makaticbd-990x530.jpg" alt="building">
				  <figcaption>City</figcaption>
				</figure>
				
				<figure data-category="landscape">
				  <img src="https://cdn10.bostonmagazine.com/wp-content/uploads/sites/2/2017/08/sunflower-field-new-england.jpg" alt="sunflowers">
				  <figcaption>Sunflower fields</figcaption>
				</figure>
				
				<figure data-category="animals" >
				  <img src="https://i.ytimg.com/vi/xkxjNZComZg/maxresdefault.jpg" alt="hamster">
				  <figcaption>Animals - Hamster</figcaption>
				</figure>
				
				<figure data-category="animals">
				  <img src="https://r.hswstatic.com/w_907/gif/tesla-cat.jpg" alt="cat">
				  <figcaption>Animal - Cat</figcaption>
				</figure>
				
				<figure data-category="building" >
				  <img src="https://images.pexels.com/photos/302769/pexels-photo-302769.jpeg" alt="building">
				  <figcaption>Building in a street</figcaption>
				</figure>
			</div>
		</main>
	</div>
</div>
<div class="overlay">
</div>
              
            
!

CSS

              
                *, *:after, *:before {
	box-sizing: inherit;
}

html {
	box-sizing: border-box;
	font-size: 10px;
}
body {
	font-size: 1.7rem;
	background-color: #a0a0d0;
}

a {
	color: black;
	text-decoration: none;
}
h1 {
	font-size: 2.4rem;
}
h2 {
	font-size: 2.3rem;
}
h3 {
	font-size: 2.2rem;
}
.container {
	width: 95%;
	margin: 0 auto 3rem;
	background: #d1d1d1;
	padding: 0 1em;
	border-radius: 0 0 10px 10px;
	box-shadow: 1px 1px 10px black;
	@media (min-width: 640px) {
	width: 80%;	
	}
}

img {
	width: 100%;
	display: block;
}

header .hero {
	background: url('http://interfacelift.com/wallpaper/previews/02105_blueforest_672x420.jpg') no-repeat;
	background-size: cover;
	height: 20vh;
	display:block;
	position: relative;
	z-index: 1;
}

#profileDetails {
	
	.logo {
		width: 40%;
		margin: 0 auto;
		padding: 1em 0;
		
		@media (min-width: 640px) {
			width: 30%;	
		}
	}
	.profile {
		@media (min-width: 640px) {
			width: 50%;
		}
	}
	.socialLinks .fa {
		font-size: 5rem;
		color: slateblue;
		padding: 0 2rem 0 0;
		transition: all .5s ease-out;
		&:hover {
			color: darken(slateblue, 40%);
		}
	}
	@media (min-width: 640px) {
		display: flex;
		justify-content: space-between;
	}
}
header.tabs {
	cursor:pointer;
	@media (min-width: 640px) {
		border-radius: 15px;
		display: flex;
		justify-content: space-between;
	}
}
.tabBorder {
	border-bottom: 15px solid slateblue;
}
.tab {
	width: 100%;
	background-color: slateblue;
	color: white;
	font-weight: 700;
	padding: 1em;
	text-align: center;
	margin: .5em 0;
	transition: all .5s ease-out;
	@media (min-width: 640px) {
		border-radius: 10px 10px 0 0;
		margin: .5em .5em 0;
		padding: .5em 0;
	}
	&:hover {
		background-color: darken(slateblue, 10%);
	}
}
main .gallery {
	display: flex;
	flex-wrap:wrap;
	
	figure {
		width: 45%;
		margin: 2.5%;
		border: 5px solid white;
		box-shadow: 1px 1px 10px black;
		
		figcaption {
			padding: 1em .5em;
			background-color: rgba(0,0,0,.2);
		}
		@media (min-width:740px) {
			width: 28%;
		}
		
		@media (min-width:1024px) {
			width: 20%;
		}
	}
}

.overlay {
	position: absolute;
	height: 100vh;
	top: 0;
	background-color: rgba(0,0,0, 0.8);
	z-index: 2;
	width: 100%;
	display: none;
	
	img {
		border: 25px solid white;
		border-radius: 10px;
		position: absolute;
		top: 25vh;
		left: 4%;
		width: 92%;
		margin: 0 auto;
		display:block;
	}
	#close {
		position: absolute;
		z-index: 3;
		top: 25.5vh;
		right: 4.5%;
		display: none;
	}
	.fa {
		color: black;
		font-size:20px;
		transition: all .5s ease-out;
			&:hover {
				color: tomato;
				transform: rotate(20deg);
			}
		}
}

              
            
!

JS

              
                let figures = document.querySelectorAll('figure');
let images = document.querySelectorAll('figure img');

let overlay = document.querySelector('.overlay');
let tab = document.querySelectorAll('.tab');
let closeBtn;

// loop and add eventlistener on click.
Array.from(images).forEach(image => {
	image.addEventListener('click', function(){
	
	// assign image src and alt to src and alt variables.
	let src = image.src;
	let alt = image.alt;
	// turning the overlay div to block;
	overlay.style.display = 'block';
		
	// adding the image and close button inside the overlay div.
	overlay.innerHTML = `<img src="${src}" alt=${alt}/>
								<div id="close">
								<i class="fa fa-window-close-o" aria-hidden="true"></i>
								</div>`;
		
	// Selecting the close element
	closeBtn = document.getElementById('close');
	// setting the close button to block
	closeBtn.style.display = 'block';
		
		// Close function -- to Close Image
		closeBtn.addEventListener('click', function(){
			//setting the overlay back to none
			overlay.style.display = 'none';
		})
	});
});

// Click event on the TABS ------ to filter photos.
Array.from(tab).forEach(t => {
	t.addEventListener('click', (e)=>{
		
		// if all photos - Display them all.
		if(e.target.textContent === 'All'){
			
			Array.from(figures).forEach(fig => {
			let data = fig.dataset.category;
				
				if(data){
					console.log(data);
					fig.style.display = 'block';
				}
			});
			
		} else if (e.target.textContent == 'Animals') {
			
			Array.from(figures).forEach(fig => {
				let data = fig.dataset.category;
				data != 'animals' ? fig.style.display = 'none' : fig.style.display = 'block';
			
			});
			
		} else if (e.target.textContent === 'Landscapes') {
			// console.log('landscape photos')
			Array.from(figures).forEach(fig => {
				let data = fig.dataset.category;
				//nsole.log(data);
				data != 'landscape' ? fig.style.display = 'none' : fig.style.display = 'block';
			});
		} else if (e.target.textContent === 'Buildings') {
			// console.log('landscape photos')
			Array.from(figures).forEach(fig => {
				let data = fig.dataset.category;
				//nsole.log(data);
				data != 'building' ? fig.style.display = 'none' : fig.style.display = 'block';
			});
		}
	})
});


              
            
!
999px

Console