JSFiddle - React, Tailwind, and code Playground

HTML

<div class="gallery">
	<div class="galleryInner">
		<div class="galleryCol col45">
			<a 
			href="https://cdn.fishki.net/upload/post/2017/03/19/2245758/tn/02-funny-cat-wallpapercat-wallpaper.jpg" 
			class="galleryItem" 
			style="background-image: url('https://cdn.fishki.net/upload/post/2017/03/19/2245758/tn/02-funny-cat-wallpapercat-wallpaper.jpg')"></a>
		</div>

		<div class="galleryCol col30">
			<a 
			href="https://cdn.fishki.net/upload/post/2017/03/19/2245758/tn/02-funny-cat-wallpapercat-wallpaper.jpg" 
			class="galleryItem" 
			style="background-image: url('https://cdn.fishki.net/upload/post/2017/03/19/2245758/tn/02-funny-cat-wallpapercat-wallpaper.jpg')"></a>
		</div>

		<div class="galleryCol col25">
			<a 
			href="https://cdn.fishki.net/upload/post/2017/03/19/2245758/tn/02-funny-cat-wallpapercat-wallpaper.jpg" 
			class="galleryItem" 
			style="background-image: url('https://cdn.fishki.net/upload/post/2017/03/19/2245758/tn/02-funny-cat-wallpapercat-wallpaper.jpg')"></a>
		</div>
		
		<div class="galleryCol col25">
			<a 
			href="https://cdn.fishki.net/upload/post/2017/03/19/2245758/tn/02-funny-cat-wallpapercat-wallpaper.jpg" 
			class="galleryItem" 
			style="background-image: url('https://cdn.fishki.net/upload/post/2017/03/19/2245758/tn/02-funny-cat-wallpapercat-wallpaper.jpg')"></a>
		</div>

		<div class="galleryCol col45">
			<a 
			href="https://cdn.fishki.net/upload/post/2017/03/19/2245758/tn/02-funny-cat-wallpapercat-wallpaper.jpg" 
			class="galleryItem" 
			style="background-image: url('https://cdn.fishki.net/upload/post/2017/03/19/2245758/tn/02-funny-cat-wallpapercat-wallpaper.jpg')"></a>
		</div>

		<div class="galleryCol col30">
			<a 
			href="https://cdn.fishki.net/upload/post/2017/03/19/2245758/tn/02-funny-cat-wallpapercat-wallpaper.jpg" 
			class="galleryItem" 
			style="background-image: url('https://cdn.fishki.net/upload/post/2017/03/19/2245758/tn/02-funny-cat-wallpapercat-wallpaper.jpg')"></a>
		</div>
	</div>
</div>

CSS

* {
	box-sizing: border-box;
}

body {
	margin: 0;
}

.gallery {
	padding: 0 10px;
}

.galleryInner {
	display: flex;
	flex-flow: row wrap;
	margin: 0 -10px;
}

.galleryCol {
	flex: 0 0 auto;
	padding: 0 10px;
}

.galleryCol.col25 {
	flex-basis: 25%;
}

.galleryCol.col30 {
	flex-basis: 30%;
}

.galleryCol.col45 {
	flex-basis: 45%;
}

.galleryItem {
	position: relative;
	
	display: block;
	margin-bottom: 20px;
	height: 200px;
	
	background: #000 center / cover no-repeat;
}

.galleryItem:after {
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	
	transition: .2s ease-in-out;
	
	background-color: rgba(0,0,0,.3);
	opacity: 0;
	
	content: '';
}

.galleryItem:hover:after {
	opacity: 1;
}

@media (max-width: 768px) {
	.galleryCol.col25,
	.galleryCol.col30,
	.galleryCol.col45 {
		flex-basis: 50%;
	}
}

@media (max-width: 500px) {
	.galleryCol.col25,
	.galleryCol.col30,
	.galleryCol.col45 {
		flex-basis: 100%;
	}
}