Favorites

cross-fade() CSS Function

cross-fade()
CSS FunctionThis function is supported in some modern browsers, but not all.
Updated 21st November 2026

The cross-fade() function blends two or more images together by percentages, creating a new image.

Looks like you're using an ad blocker, and that's fine! Ads help keep CSS Portal's generators and references free, so if the site's useful to you, visit our Support page to see other ways to help.

Description

The cross-fade() CSS function blends two or more images together, producing a new image in which each input is shown at a chosen level of transparency. It is like stacking pictures on top of each other with different opacities, but the result is a single <image> value that can be used in properties such as background-image, without extra elements or pseudo-elements.

In the current specification, each argument is an image (or a color) followed by an optional percentage that sets how much of it shows. If percentages are left out, the remaining amount is shared equally between the images that have none. Colors are treated as solid images, so you can, for example, fade a photo toward black. Because the percentages control the blend directly, cross-fade() can also be animated between states to create smooth transitions between two backgrounds.

Browser support is limited. Chromium-based browsers support only the older prefixed form, -webkit-cross-fade(image1, image2, percentage), in which the percentage is the amount of the second image. Safari supports this older two-image form without a prefix, and Firefox does not support the function at all. Always provide a plain background as a fallback.

.photo {
  background-image: url("day.jpg"); /* fallback */
  background-image: -webkit-cross-fade(url("day.jpg"), url("night.jpg"), 30%);
  background-image: cross-fade(url("day.jpg") 70%, url("night.jpg") 30%);
}

/* Darken an image by fading it with black */
.hero {
  background-image: cross-fade(url("hero.jpg") 60%, black);
}

Syntax

cross-fade() = cross-fade( <cf-image># )

<cf-image> = [ <image> | <color> ] && <percentage [0,100]>?

/* Older form supported by browsers */
-webkit-cross-fade( <image>, <image>, <percentage> )

Values

  • <image> | <color>An image to blend, or a color, which is treated as a solid-color image.
  • <percentage>Optional. How much of that image is used, from 0% to 100%. Images without a percentage share whatever is left over equally. In the older -webkit- form, a single percentage sets the amount of the second image.

Example

<div class="wrap">
<h1>CSS cross-fade() examples</h1>
<div class="grid">
<div class="card">
<div class="box a"></div>
<div class="label">image 1</div>
</div>
<div class="card">
<div class="box b"></div>
<div class="label">image 2</div>
</div>
<div class="card">
<div class="box mix25"></div>
<div class="label">-webkit-cross-fade(image 1, image 2, 25%)</div>
</div>
<div class="card">
<div class="box mix60"></div>
<div class="label">-webkit-cross-fade(image 1, image 2, 60%)</div>
</div>
</div>
<p class="note">Uses the prefixed form supported by Chromium and Safari. Firefox shows the fallback gradient.</p>
</div>
/* Base demo layout */
* { box-sizing: border-box; }

body {
margin: 24px;
font-family: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial;
background: #f5f7fb;
color: #102a43;
}

.wrap {
max-width: 860px;
margin: 0 auto;
}

h1 {
font-size: 20px;
margin: 0 0 16px;
}

.grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
gap: 16px;
}

.card {
background: #fff;
border-radius: 12px;
padding: 16px;
box-shadow: 0 6px 18px rgba(16, 42, 67, 0.08);
}

.label {
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, monospace;
font-size: 12px;
color: #486581;
margin-top: 10px;
word-break: break-word;
}

.note {
font-size: 13px;
color: #486581;
margin-top: 14px;
}

/* cross-fade() examples */
.box {
height: 140px;
border-radius: 12px;
/* fallback for browsers without cross-fade() */
background-image: linear-gradient(135deg, #2563eb, #06b6d4);
}

.a { background-image: linear-gradient(135deg, #2563eb, #06b6d4); }
.b { background-image: repeating-linear-gradient(45deg, #f97316 0 14px, #fde047 14px 28px); }

.mix25 {
background-image: -webkit-cross-fade(
linear-gradient(135deg, #2563eb, #06b6d4),
repeating-linear-gradient(45deg, #f97316 0 14px, #fde047 14px 28px),
25%
);
}

.mix60 {
background-image: -webkit-cross-fade(
linear-gradient(135deg, #2563eb, #06b6d4),
repeating-linear-gradient(45deg, #f97316 0 14px, #fde047 14px 28px),
60%
);
}
Open in editor

Browser Support

The following information will show you the current browser support for the CSS cross-fade() function. Hover over a browser icon to see the version that first introduced support for this CSS function.

This function is supported in some modern browsers, but not all.

Desktop

Chrome
Edge
Firefox
Opera
Safari

Tablets & Mobile

Chrome Android
Firefox Android
Opera Android
Safari iOS
Samsung Internet
Android WebView
-
Supported Unknown Not supported

Looks like you're using an ad blocker, and that's fine! Ads help keep CSS Portal's generators and references free, so if the site's useful to you, visit our Support page to see other ways to help.