WEB TUTORIALS
PRACTICE EXAMPLES
HTML REFERENCES
CSS REFERENCES
PHP REFERENCES

How to Combine Background Image and CSS3 Gradient on the Same Element

Topic: JavaScript / jQueryPrev|Next

Answer: Use the CSS3 Multiple Backgrounds

You can simply use the CSS3 multiple backgrounds feature to apply or combine the background-image and CSS3 gradient on the same element. These are layered one on the top of another, where the first background you specify will appear on the top, whereas the last background in the list will appear at the bottom. Only the last background can include a background-color.

Let's try out the following example to understand how it basically works:

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Apply Background-image and CSS3 Gradient on the Same Element</title>
<style>
    .box{
        height: 400px;
        background: linear-gradient(transparent, black), url("images/sky.jpg") no-repeat center, lightblue;
        background-size: cover;
    }
</style>
</head>
<body>
    <div class="box"></div>
</body>
</html>

Related FAQ

Here are some more FAQ related to this topic:

Bootstrap UI Design Templates Property Marvels - A Leading Real Estate Portal for Premium Properties