Creating a beautiful rays gradient banner can make your website look more attractive and professional. This step-by-step guide will help you understand how to create a rays gradient banner using simple HTML and CSS. We will use the keywords “rays gradient banner,” “gradient banner HTML,” “source code,” “codepen,” and “rays background codepen” throughout the article.
A gradient banner is a web design element with a gradient background with rays of light radiating from a central point. This effect will grab the attention of the visitors and make your website stand out.
Table of Contents
HTML and CSS Code for Rays Gradient Banner
Here is the complete code for creating a rays gradient banner. Let’s break it down step by step.
Rays Background - Md Asik
An awesome title
HTML Structure: The HTML file starts with the basic structure, including the <!DOCTYPE html>
, <html>
, <head>
, and <body>
tags. The title of the page is set to “Rays Background – Md Asik.”
CSS Styles: The CSS styles are defined within the <style>
tag inside the <head>
section.
- Custom Properties: The
--blink-opacity
custom property is defined using@property
to control the blinking animation’s opacity. - Base Styles: The
:root
selector sets the default font family and colors. Thebody
selector sets the overall layout and background color. - Animations: Keyframes for
blink-animation
andsmoothBg
are defined to create smooth background movement and blinking effects. - Wrapper and Hero Classes: The
.wrapper
class sets the overall structure. The.hero
class defines the repeating linear gradients for stripes and rainbow effects, along with various properties likebackground-image
,background-size
, andfilter
.
Content and Heading: The .content
class styles the content inside the banner, including the heading with a scaling size effect and the switch button with custom animations.
Hero Section: The hero section contains the background effects. The background-image
property uses repeating linear gradients to create stripes and rainbow patterns. The mask-image
property and filter
are used to create a radial gradient and blur effects.
Content Section: The content section includes a heading and a checkbox switch to change the background. The heading uses the data-text
attribute to display a dynamic title. The checkbox and label allow users to toggle the background effect.
Switch Button: The switch button is styled to appear hidden, and the label associated with it includes a cursor pointer and animation for a smooth transition.
Icon and Animation: The .icon
class and blink-animation
keyframe create a blinking effect for the icon inside the switch button.
Responsive Design: The CSS code ensures that the banner is responsive and adapts to different screen sizes, making it look good on both desktop and mobile devices.
Rays Gradient Banner for Elementor
This CSS code is designed to style elements, particularly within an Elementor page builder environment.
.hero {
width: 100%;
height: 100%;
min-height: 100vh;
position: relative;
display: flex;
place-content: center;
place-items: center;
background-image: repeating-linear-gradient(
100deg,
#fff 0%,
#fff 7%,
transparent 10%,
transparent 12%,
#fff 16%
), repeating-linear-gradient(
100deg,
#60a5fa 10%,
#e879f9 15%,
#60a5fa 20%,
#5eead4 25%,
#60a5fa 30%
);
background-size: 300%, 200%;
background-position: 50% 50%, 50% 50%;
filter: blur(10px) invert(100%);
mask-image: radial-gradient(ellipse at 100% 0%, black 40%, transparent 70%);
}
.hero::after {
content: "";
position: absolute;
inset: 0;
background-image: repeating-linear-gradient(
100deg,
#fff 0%,
#fff 7%,
transparent 10%,
transparent 12%,
#fff 16%
), repeating-linear-gradient(
100deg,
#60a5fa 10%,
#e879f9 15%,
#60a5fa 20%,
#5eead4 25%,
#60a5fa 30%
);
background-size: 200%, 100%;
animation: smoothBg 60s linear infinite;
background-attachment: fixed;
mix-blend-mode: difference;
}
/*custom*/
@keyframes smoothBg {
from {
background-position: 50% 50%, 50% 50%;
}
to {
background-position: 350% 50%, 350% 50%;
}
}
.hero.dark,
.hero.dark::after {
filter: blur(10px) opacity(50%) saturate(200%);
}
.hero.dark {
background-image: repeating-linear-gradient(
100deg,
#000 0%,
#000 7%,
transparent 10%,
transparent 12%,
#000 16%
), repeating-linear-gradient(
100deg,
#60a5fa 10%,
#e879f9 15%,
#60a5fa 20%,
#5eead4 25%,
#60a5fa 30%
);
}
.hero.dark::after {
background-image: repeating-linear-gradient(
100deg,
#000 0%,
#000 7%,
transparent 10%,
transparent 12%,
#000 16%
), repeating-linear-gradient(
100deg,
#60a5fa 10%,
#e879f9 15%,
#60a5fa 20%,
#5eead4 25%,
#60a5fa 30%
);
}
.content {
position: absolute;
inset: 0;
width: 100%;
height: 100%;
display: flex;
place-content: center;
place-items: center;
flex-flow: column;
gap: 4.5%;
text-align: center;
mix-blend-mode: difference;
-webbkit-mix-blend-mode: difference;
filter: invert(1);
}
Click here to download the file
DOWNLoAD NoWYour File will download in 15 seconds...
Video Preview
Conclusion
By following this step-by-step guide, you can create a stunning rays gradient banner for your website using Elementor. The combination of HTML and CSS allows you to achieve a professional-looking design with smooth animations and interactive elements. Feel free to experiment with the code and customize it to fit your needs. This unique and easy-to-index content will help your website stand out and attract more visitors.
I hope this code helps you How to Create a Stunning Rays Gradient Banner. If you have any doubts or problem with the code, comment below to find the solutions. Also share this blog if you find this useful.
Want to build professional website for your Business or Store, Get a free quote here
Click here to get Premium Plugins and Themes at rs.249. Get 20% Off on your first order “WELCOME20”