Responsive Hero Section with Background Image and Gradient using HTML & CSS

Responsive Hero Section with Background Image and Gradient using HTML & CSS

Hello developers, today in this blog, you'll learn to create a Responsive Hero Section with Background Image and Gradient using HTML & CSS.

A hero section is a full-screen section that consists of a background image, or video, or illustrations, or animations, with some text and a button which will redirect to the linked page. The hero section is a website design term that is used to describe an oversized banner image at the top of a website that usually extends full width.

A hero section should consist of a title, a short description, a high-quality image or video, and a link to direct the user to the other page. Hero images are used to catch the visitor's attention and draw them into reading the article on the page.

In this blog (Responsive Hero Section with Background Image and Gradient), there is a heading, a title, a short description, a button which is named Click Me and there is a high-quality background image. Usually, the background of the webpage will consist of either the linear gradient or an image. Whereas in this webpage, the background image is used with a linear gradient, that is the linear gradient is overlayered in the image. The CSS media query property is used to make the page responsive.

The source code of this Responsive Hero Section with Background Image and Gradient is given below, if you want the source code of this program, you can copy it. You can use this Responsive Hero Section with Background Image and Gradient with your creativity and can take this project to the next level.

Responsive Hero Section with Background Image and Gradient [Source Code]

To make this website, you would like to make two files: an HTML file & a CSS file. First, create an HTML file with the name of index.html and remember, you have to create a file with a .html extension.

<!DOCTYPE html> <html> <head> <title>Responsive Hero Section with Background Image and Gradient|| Learningrobo</title> <link rel="stylesheet" href="style.css"> <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css"> </head> <body> <div class="hero"> <div class="container"> <div class="info"> <h1>Title</h1> <h2>Lorem ipsum dolor sit amet consectetur.</h2> <p>Lorem ipsum, dolor sit amet consectetur adipisicing elit. Voluptatem vero ratione vitae dicta explicabo perferendis amet quis provident molestiae magni!</p> <a class="click" href="https://www.learningrobo.com/">Click Me</a> <div class="credit">Made with <span style="color:tomato">❤</span> by <a href="https://www.learningrobo.com/">Learning Robo</a></div> </div> </div> </div> </body> </html>
CSS provides style to an HTML page. To make the page attractive and responsive create a CSS file with the name style.css and remember that you have to make a file with a .css extension.


* {
    padding: 0;
    margin: 0;
    font-family: sans-serif;
}
.hero{
    width: 100%;
    height: 100vh;
    background-image: linear-gradient(rgba(0,0,0, 0.7),rgba(255,0,0, 0.2)),url(https://cdn.pixabay.com/photo/2017/01/30/16/11/sunset-2021266__340.jpg);
    background-position: center;
    background-size: cover;
    position: relative;
    color: #fff;
}
.container {
  width: 90%;
  height: 100%;
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: left;
}
.info h1 {
  font-size: 3rem;
  margin-bottom: .5rem;
  font-family: cursive;
}
.info h2 {
    font-family: cursive;
  font-size: 1.5rem;
  margin-bottom: 2rem;
}
.info p {
  font-size: 1.2rem;
  max-width: 50%;
}
.info .click{
  text-decoration: none;
  display: inline-block;
  background-color: #fff;
  border-radius: 4px;
  font-size: 1rem;
  padding: 0.5em 2em;
  margin-top: 2rem;
  color: black;
}
@media only screen and (max-width: 768px) {
  html {
    font-size: 10px;
  }
}
.credit a{
    text-decoration: none;
    color: #fff;
    font-weight: 800;
}
.credit {
    margin-top: 10px;
    font-size: 1.2rem;
}
We hope you would like this Responsive Hero Section with Background Image and Gradient using HTML & CSS.

Thank you for reading our blog. If you face any problem in creating this Responsive Hero Section with Background Image and Gradient using HTML & CSS, then contact us or comment us. We’ll try to provide a solution to your problem as soon as possible.

Thank you
Learning robo team

إرسال تعليق

Thank you
Learning robo team

Post a Comment (0)

أحدث أقدم
Learning Robo says...
code copied
Welcome