Overlay Background CSS 3

Overlay Background CSS 3

Tutorial kali ini akan membahas masih diseputar overlay dengan menggunakan CSS 3, hanya sedikit ada penambahan efek yaitu merubah background pada setiap elemen.

Skripnya secara keseluruhan adalah sebagai berikut:

<!DOCTYPE html>
<html>
<head>
	<title>Overlay Change</title>
	<!-- CSS -->
	<link rel="stylesheet" type="text/css" href="overlay.css">

	<!-- FontAwesome CDN -->
	<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.1/css/all.min.css">
</head>
<body>


	<div class="main-wrap">
		<a class="main-hover" href="#">
			<div class="box-item">
				<div class="icon-item">
					<i class="fas fa-cogs"></i>
				</div>
				<div class="icon-bg">
					<i class="fas fa-cogs my-bg"></i>
				</div>
				<h4>Corporate Solution</h4>
				<p>Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old.</p>
			</div>
		</a>

		<a class="main-hover" href="#">
			<div class="box-item">
				<div class="icon-item">
					<i class="fas fa-business-time"></i>
				</div>
				<div class="icon-bg">
					<i class="fas fa-business-time my-bg"></i>
				</div>
				<h4>Archive</h4>
				<p>Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old.</p>
			</div>
		</a>

		<a class="main-hover" href="#">
			<div class="box-item">
				<div class="icon-item">
					<i class="fas fa-charging-station"></i>
				</div>
				<div class="icon-bg">
					<i class="fas fa-charging-station my-bg"></i>
				</div>
				<h4>Charging Station</h4>
				<p>Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old.</p>
			</div>
		</a>

	</div>

</body>
</html>

Untuk skrip diatas tersebut adalah .html-nya sedangkan untuk skrip style css, ada dibawah ini:

/* Import Google Font */
@import url('https://fonts.googleapis.com/css2?family=Istok+Web&family=Montserrat:wght@700&display=swap');


/* CSS RESET */

*{
	padding: 0;
	margin: 0;
}

.main-wrap{
	padding-top: 50px;
	margin: auto;
	width: 1200px;
	height: 400px;
	/*background-color: green;*/
}

.box-item{
	width: 350px;
	height: 315px;
	overflow: hidden;
	position: relative;
	border: 1px solid #d4d4e1;
	border-radius: 6px;
	padding: 30px 10px;
	transition: 0.5s ease-out;
	margin-right: 25px;
}

.main-hover{
	text-decoration: none;
	display: inline-block;
}

.main-hover:hover .icon-item{
	color: #2c7ae7;
	background: #ffffff;
	transition: 0.5s ease-out;
}

.main-hover:hover .box-item{
	background-color: #2c7ae7;
	transition: 0.5s ease-out;
}

.main-hover:hover .icon-bg .fas{
	color: rgb(0, 0, 0, 0.1);
}

.main-hover:hover .box-item h4{
	color: #ffffff;
}

.main-hover:hover .box-item p{
	color: #ffffff;
}


.icon-item{
	margin: auto;
	justify-content: center;
	display: flex;
	align-items: center;
	background: linear-gradient(to right,#2876e2 0,#3f8efc 100%);
	height: 97px;
	width: 97px;
	border-radius: 50%;
	z-index: 2;
	position: relative;
	transition: 0.5s ease-out;
}

.icon-item{
	font-size: 48px;
	color: #fff;
}

.icon-bg .my-bg{
	font-size: 300px;
	color: #ffffff;
}

.icon-bg{
	overflow: hidden;
	position: absolute;
	top: 0;
	left: 0;
	z-index: 1;
}

.box-item h4{
	font-size: 24px;
	z-index: 2;
	position: relative;
	font-family: 'Montserrat', sans-serif;
	font-weight: 700;
	text-align: center;
	color: #212529;
	margin-top: 10px;
	margin-bottom: 10px;
}

.box-item p{
	font-size: 16px;
	color: #ffffff;
	font-family: 'Istok Web', sans-serif;
	font-weight: 400;
	color: #303036;
	position: relative;
	z-index: 2;
	text-align: center;
	line-height: 1.7;
}

Berikut ini adalah hasil jadinya: