The hero section of your website is the first thing visitors see, and it should leave a lasting impression. In this tutorial, we'll guide you through the process of creating a visually stunning hero section using HTML and CSS. Elevate your web design skills and make your website more engaging with this essential design element.
Step 1: HTML Markup:
Start by setting up the HTML structure for your hero section, creating a container for the hero content.
<!-- -------------------- HTML -------------------- -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<section class="hero">
<!-- navbar start -->
<div class="navbar">
<div class="logo">
<img src="img/logo.png" alt="">
<span>LOGO</span>
</div>
<ul class="link">
<li><a class="active" href="#">Home</a></li>
<li><a href="#">Blog</a></li>
<li><a href="#">Gallery</a></li>
<li><a href="#">About</a></li>
<li><a href="#">Sign In</a></li>
</ul>
</div>
<!-- navbar End -->
<!-- main start -->
<main>
<!-- textarea start -->
<div class="textArea">
<h1>FUTURE OF <br> <span>TECHNOLOGY</span></h1>
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Sed possimus labore blanditiis, repellat
fuga suscipit soluta assumenda ipsum neque deserunt quasi, molestiae eos ipsa porro.</p>
<div>
<button class="btn btn_dark">Learn More</button>
<button class="btn btn_light">Contact Us</button>
</div>
</div>
<!-- textarea End -->
<!-- imageArea start -->
<div class="imageArea">
<img class="img img1" src="img/box ic.png" alt="">
<img class="img img2" src="img/cercitBG.png" alt="">
<img class="img img3" src="img/ctrl alt.png" alt="">
<img class="img img4" src="img/enter.png" alt="">
<img class="img img5" src="img/file.png" alt="">
<img class="img img6" src="img/geair1.png" alt="">
<img class="img img7" src="img/geair1.png" alt="">
<img class="img img8" src="img/geair1.png" alt="">
<img class="img img9" src="img/ware1.png" alt="">
<img class="img img10" src="img/file down.png" alt="">
</div>
<!-- imageArea end -->
</main>
<!-- main End -->
<!-- footer start -->
<div class="footer">
<img src="img/cercit1.png" alt="">
<div class="social"><a href="#">FOLLOW US</a> SOCIAL MEDIA</div>
</div>
</section>
</body>
</html>
Step 2: Styling with CSS:
Create a separate CSS file (style.css)
/*-------------------- CSS --------------------*/
*{
margin: 0;padding: 0;box-sizing: border-box;
font-family: sans-serif;
}
body{
min-height: 100vh;
overflow: hidden;
position: relative;
background: #bfbfbf;
}
.hero{
width: 100%;
height: 100%;
position: relative;
}
.navbar{
width: 100%;
height: 10vh;
display: flex;
align-items: center;
padding: 60px 100px 0 100px;
}
.logo{
height: 40px;
font-size: 30px;
color: black;
display: flex;
align-items: center;
font-weight: 700;
cursor: pointer;
}
.logo img{
margin-right: 10px;
height: 100%;
}
.link{
display: flex;
margin-left: 150px;
width: 100%;
justify-content: end;
}
.link li {
list-style: none;
margin: 0 20px;
transition: 0.4s;
border-bottom: 2px solid transparent;
}
li a{
text-decoration: none;
color: white;
position: relative;
top: 0;
transition: 0.4s;
font-size: 20px;
}
li:hover{
border-bottom: 2px solid white;
}
li:hover a{
top: -4px;
}
.active{
color: #00ffaa;
font-weight: 600;
}
/* main start */
main{
width: 100%;
height: 80vh;
display: flex;
padding: 50px 100px;
}
.textArea{
width: 50%;
height: 100%;
display: flex;
flex-direction: column;
justify-content: center;
}
h1{
font-size: 60px;
font-weight: 300;
color: white;
line-height: 3.5rem;
}
h1 span{
color: black;
font-weight: 900;
}
p{
color: white;
margin-top: 20px;
}
.btn{
width: 150px;
height: 50px;
border-radius: 12px;
outline: none;
font-size: 16px;
color: white;
margin-top: 70px;
cursor: pointer;
}
.btn_dark{
background: black;
border: 1px solid black;
margin-right: 30px;
}
.btn_dark:hover{
background: transparent;
border: 1px solid white;
}
.btn_light{
background: transparent;
border: 1px solid white;
}
.btn_light:hover{
background: black;
border: 1px solid black;
}
/* image area */
.imageArea{
position: relative;
width: 50%;
height: 100%;
}
.imageArea img{
position: absolute;
}
.img1{
width: 30%;
top: 60%;
right: 10%;
}
.img2{
width: 100%;
top: 0;
right: 0;
}
.img3{
width: 18%;
top: 10%;
right: 50%;
animation: flote 3s linear infinite alternate;
}
.img4{
width: 20%;
top: 65%;
right: 80%;
animation: flote 5s linear infinite alternate-reverse;
}
.img5{
width: 40%;
top: 20%;
right: 15%;
}
.img6{
width: 10%;
top: 400px;
right: 300px;
animation: rotate 15s linear infinite;
}
.img7{
width: 10%;
top: 480px;
right: 360px;
animation: rotate 15s linear infinite;
}
.img8{
width: 7%;
top: 500px;
right: 300px;
animation: rotate 10s linear infinite;
}
.img9{
width: 45%;
top: 30%;
right: 40%;
}
.img10{
width: 25%;
top: 7%;
right: 65%;
}
@keyframes flote {
0%{
transform: translateY(0);
}
100%{
transform: translateY(20px);
}
}
@keyframes rotate {
0%{
transform: rotate(0);
}
100%{
transform: rotate(360deg);
}
}
/* footer */
.footer{
position: relative;
text-align: center;
height: 10vh;
padding-top: 30px;
}
.footer img{
position: absolute;
top: 0;
left: 0;
height: 150px;
transform: translateY(-50%);
}
.social{
color: #efefef;
letter-spacing: .2rem;
}
.social a{
text-decoration: none;
color: white;
}
.social a:hover{
color: #efefef;
}
Customize your hero section by modifying the text, background image, colors, and styling to match your website's theme. This design element sets the stage for an impactful user experience.
0 Comments