×

Combine Background Image with Gradient Overlay

With the help of CSS gradient, we can display smooth and straightforward transitions between two or more colours. We can add the background images by combining the gradient property with the URL (Uniform Resource Locator) of background images.

Syntax:

The syntax for linear gradient on top background images is as below.

element {
background-image: linear-gradient(direction, 
color-stop1, color-stop2, ...), url('url');
}

The syntax for radial gradient on top background images is as below.

element {
background-image: radial-gradient(direction, 
color-stop1, color-stop2, ...), url('url');
}

Example 1

It is an example of the linear gradient for background images.

HTML code

<!DOCTYPE html>
<html lang="en">


<head>
	<title>Background Image with Linear Gradient</title>
	<meta charset="utf-8">
	<meta name="viewport"
content="width=device-width, initial-scale=1">
	<link rel="stylesheet"
href=
"https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
	<style>
.my_bg {
background-image:
linear-gradient(45deg,
rgba(245,70,66, 0.75),
rgba(8,83,156, 0.75)), url(
'https://static.javatpoint.com/images/logo/jtp_logo.png');
width: 100%;
height: 280px;
text-align: center;
color: #fff;
}
	</style>
</head>


<body>
	<div class="my_bg">
<h3>Welcome to javaTpoint</h3>
	</div>
</body>


</html>

Output:

Combine Background Image with Gradient Overlay

Example 2

It is an example of the radial gradient for background images.

HTML code

<!DOCTYPE html>
<html lang="en">


<head>
	<title>Background Image with Radial Gradient</title>
	<meta charset="utf-8">
	<meta name="viewport"
content="width=device-width, initial-scale=1">
	<link rel="stylesheet"
href=
"https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
	<style>
.my_bg {
background-image: radial-gradient(
rgba(255, 49, 3, 0.896),
rgba(251, 255, 0, 0.75)), url(
'https://static.javatpoint.com/images/logo/jtp_logo.png');
width: 100%;
height: 250px;
text-align: center;
}
	</style>
</head>


<body>
	<div class="my_bg">
<h4>Welcome to javatpoint</h4>
	</div>
</body>


</html>

Output:

Combine Background Image with Gradient Overlay

Related Topics

CSS Dropdowns

Dropdowns are one of the maximum crucial parts of an interactive internet site. CSS is a kind used to design the drop-down menus. A drop-down essentially is a group of...

5 minutes read.

CSS Comments

CSS Comments: Generally, comments in CSS are used to describe our code. Further, it will provide support to many users who are concerned with the code. Somewhat, these are ignored...

2 minutes read.

What is CSS used for

What is CSS used for? CSS stands for Cascading Style Sheet. CSS is a stylesheet language for web pages. It specifies how a document created in a markup language looks and...

4 minutes read.

Untitled Reusable Block

  ...

1 minute read.

CSS Margin

CSS Margin: The CSS margin property is employed to describe the space throughout the elements. It clears the range throughout the element. These properties do not have a background color...

2 minutes read.

How to change background color in CSS

How to change background color in CSS? The background-color property in CSS would be used to specify the color of an element's background. As the element's background, it uses solid colors. The...

3 minutes read.

CSS Content Property

Content Property The content attribute produces dynamic content. It can be applied with any pseudo-element ::after and ::before. These CSS properties are entirely supported inside every browser and applied to include...

5 minutes read.

How to create blinking text using CSS

The blinking effect is used in HTML and CSS to take the attraction towards a particular word or section. If you need such a blinking effect, we need to take...

2 minutes read.

CSS Math Functions

The CSS math functions permit numerical articulations. These CSS math functions can particularly be utilized in maybe unforeseen ways, for example, inside angles and shading the functions and in the...

3 minutes read.

CSS Descendant Selector

Descendant Selector The Descendant selector in CSS is used to match the descendant components of a particular component. The term descendant depicts nested in whatever place, inside a DOM tree. This...

2 minutes read.

Radial-gradient() CSS function

Radial-gradient() CSS function It defines a CSS in-built function, which produces a smooth transition among multiple colors. It is used to set any radial-gradient that is same as a background-image. This...

4 minutes read.

How to include CSS

How to include CSS CSS is included in HTML pages for formatting the documents based on the information inside a style sheet. We can add CSS in HTML documents in the following three ways: Inline...

5 minutes read.

CSS Background-blend-mode

Background-blend-mode The background-blend-mode property sets a blend mode of the component’s every background layer (color/image). It illustrates how the element background image blends well with the element background color. We can...

9 minutes read.

CSS z-index Property

CSS z-index: CSS z-index permits us to represent any visual hierarchy over a 3D plane that is the z-axis. This index can be applied to describe the positioned element’s stacking...

2 minutes read.

CSS Reference

The CSS Reference lists all of the basic standard CSS properties, pseudo-classes, pseudo-elements, and data types, for all intents and purposes functional notations, and at-rules alphabetically.  The site also includes...

5 minutes read.

CSS Gradient

CSS Gradient: The CSS gradient property is applied to show the smooth transition inside two specified colors or more than two specified colors. Need of CSS Gradient The following are a few...

4 minutes read.

CSS Overflow

CSS Overflow: The Overflow property in CSS is used to manage the content if it overflows from its container of the block level. We have seen that all the elements...

3 minutes read.

CSS Radio Button

Radio Button A radio button has been defined as an element of HTML. It can support us to take any input from the user. But it is challenging to design a...

4 minutes read.

CSS Page-break-before Attribute

Page-break-before Attribute As its name implies, the page-break-before property is applied to include page break before any element, at the time of printing any document. It adds the page break before...

5 minutes read.

CSS Overlay

CSS Overlay: It measures to cover-up something’s surface along with a coating. CSS overlay sets anything over the top area of other things. It creates a web-page more attractive. The...

8 minutes read.