Open In App
Related Articles

CSS cross-fade Property

Improve Article
Improve
Save Article
Save
Like Article
Like

The cross-fade property is used to form a kind of blend between two given images. In simple words, it is used to mix to images into one another in terms of percentage.

Syntax:

cross-fade( <image, <image>, <percentage> )

Property value:

  • It has no property values, instead, it takes two images and a number indicating the amount of blending required.

Example 1: cross-fade at 0% where the first image is white and the second image is black then blending is done in such a way that there is 85 parts of the white image and 15 parts of black.

HTML




<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width,
                   initial-scale=1.0">
    <title>CSS cross-fade Property</title>
</head>
<style>
    #box {
        width: 250px;
        height: 150px;
        /* 15 parts of black and 85 parts of white */
        background-image: -webkit-cross-fade(
            url(
            url(
    }
</style>
 
<body>
    <h1>Cross-fade</h1>
    <div id="box">
    </div>
</body>
</html>


Output:

Example 2: cross-fade at 0% where the first image is black and the second image is white then blending is done in such a way that there is 0 parts of the white image and 100 parts of black.

HTML




<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,
                initial-scale=1.0">
    <title>CSS cross-fade Property</title>
</head>
<style>
    #box {
        width: 250px;
        height: 150px;
        /* 15 parts of black and 85 parts of white */
        background-image:
            -webkit-cross-fade(
                url(
                url(
    }
</style>
 
<body>
    <h1>Cross-fade at 0%</h1>
    <div id="box">
    </div>
</body>
</html>


Output:

Supported Browsers:

  • Firefox 3.0
  • Edge
  • Chrome
  • Safari

Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out - check it out now!

Last Updated : 08 Jun, 2023
Like Article
Save Article
Previous
Next
Similar Reads
Complete Tutorials