CSS | Hue Background - GeeksforGeeks

18 Jun, 2020
Hue background is a concept of a new design methodology that focuses on clean and aesthetic looking UI. It gives the website a clean and aesthetic look. It is perfect for professional websites such as some product landing page or some organization’s home page. It also has an advanced version in which the color keeps changing and we will be looking at the advanced part only as you can make the basic one if you know how to make the advanced background.
Approach:The approach is to give a gradient background and making some borders to give it a shiny reflection kind of look. For advanced concepts, we will use keyframes to change the background color.
HTML Code:In this part, we have created a section.
<!DOCTYPE html><html lang="en">  <head>    <meta charset="UTF-8" />    <meta name="viewport"          content="width=device-width,                    initial-scale=1.0" />    <title>HUE background</title> </head>  <body>    <section><h1>GeeksforGeeks</h1></section>  </body></html>
CSS Code:For CSS, follow the below given steps.
Step 1: Apply a basic gradient background using linear-gradient
Step 2: Now apply animation property with a identifier named as animate
Step 3: Now use keyframes to rotate hue at any angle of your choice using hue-rotate.This will make the color change at each frame.We have divide the frames in three parts but you can choose to divide it according to your need
Step 4: Now use beforeselector to create left side border emerging from top.
Step 5: Now use afterselector to create right side border emerging from top.
Tip:The keyframes step is completely optional if you want basic background. The borders which give a reflective effect can be of different types. We have chosen to use the borders which are emerging from the top. You can change their emerging direction and almost everything according to your need and creativity.
section {       position: absolute;       top: 0;       left: 0;       width: 100%;       height: 100vh;       background: linear-gradient(90deg, #07f79b, #01442a);       animation: animate 20s linear infinite;     }     @keyframes animate {       0% {         filter: hue-rotate(0deg);       }        50% {         filter: hue-rotate(360deg);       }        100% {         filter: hue-rotate(0deg);       }     }      section::before {       content: "";       position: absolute;       top: 0;       left: 0;       border-top: 100vh solid transparent;       border-left: 100vh solid #fff;       opacity: 0.1;     }      section::after {       content: "";       position: absolute;       bottom: 0;       right: 0;       border-top: 100vh solid transparent;       border-right: 100vh solid #fff;       opacity: 0.1;     }      h1 {       position: absolute;       top: 50%;       left: 40%;       color: white;       font: 40px;     }
Complete Code:It is the combination of the above two sections of code.
<!DOCTYPE html><html lang="en">  <head>    <meta charset="UTF-8" />    <meta name="viewport"           content="width=device-width,                    initial-scale=1.0" />    <title>HUE background</title>    <style>      section {        position: absolute;        top: 0;        left: 0;        width: 100%;        height: 100vh;        background: linear-gradient(90deg, #07f79b, #01442a);        animation: animate 20s linear infinite;      }      @keyframes animate {        0% {          filter: hue-rotate(0deg);        }          50% {          filter: hue-rotate(360deg);        }          100% {          filter: hue-rotate(0deg);        }      }        section::before {        content: "";        position: absolute;        top: 0;        left: 0;        border-top: 100vh solid transparent;        border-left: 100vh solid #fff;        opacity: 0.1;      }        section::after {        content: "";        position: absolute;        bottom: 0;        right: 0;        border-top: 100vh solid transparent;        border-right: 100vh solid #fff;        opacity: 0.1;      }        h1 {        position: absolute;        top: 50%;        left: 40%;        color: white;        font: 40px;      }    </style>  </head>  <body>    <section><h1>GeeksforGeeks</h1></section>  </body></html>
Output:
CSS-Advanced
CSS
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Design a web page using HTML and CSS
Form validation using jQuery
Search Bar using HTML, CSS and JavaScript
How to style a checkbox using CSS?
How to fetch data from localserver database and display on HTML table using PHP ?
Roadmap to Become a Web Developer in 2022
Installation of Node.js on Linux
How to fetch data from an API in ReactJS ?
Top 10 Angular Libraries For Web Developers
Convert a string to an integer in JavaScript