Background image and gradient to the same div in CSS
This article deals with an example to demonstrate how to background-color, background-image and background shorthand property in CSS.
You may read this article How to add box-shadow in CSS?
How to add Background image to the div
.div1{
background-image: url(../images/bg.jpg);
}
How to add Background color to the div
.div2{
background-color: #0085c2;
}

How to add background image and background gradient to the same div?
.div2{
background: linear-gradient(
rgba(253,29,29,0.6),
rgba(252,176,69,0.6)
),url(../images/slide2.jpg);
}
Instead of background-image or background-color property we have to use background property which is the shorthand rule. Background-gradient and image are separated by comma.
The resultant output

Also read next article - Is your site mobile friendly?
Comments
Post a Comment