Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSS background-image fallback [duplicate]

Is there any way to specify a fallback image for a background image using CSS?

Example

.container {
  background-image: url(pics/img.webp);
  background-image-fallback: url(pics/img.png);
}
like image 480
Karl Barnholdt Avatar asked Sep 06 '25 04:09

Karl Barnholdt


2 Answers

You can use multiple images if the one doesn't exit, the second will be show.

.container {
      background-image: url(pics/img.webp), url(pics/img.png);
    }
like image 76
Vikas Jadhav Avatar answered Sep 09 '25 01:09

Vikas Jadhav


try like this.

.container {
  background: url((pics/img.webp) bottom center no-repeat,url((pics/img.webp) repeat;
}
like image 43
Nethra Avatar answered Sep 09 '25 01:09

Nethra