alexsc
alexsc

Reputation: 1206

CSS background image svg

I'm trying to use an svg image for my background image in CSS. The image is only rescaling in larger devices, it remains constant in devices with width and height smaller that the svg image size.

Here's my code :

body {
  background-image: url(svgImg.svg);
  background-repeat: no-repeat;
  background-size: cover;
}

Can you help me make the image redimension on every screen ?

Upvotes: 1

Views: 3974

Answers (1)

alexsc
alexsc

Reputation: 1206

This code made it do it, it can be written in one single line, but i'm posting every detail so it would be explanatory.

body{
background-image: url(svgImg.svg) ;
background-position: center center;
background-attachment: fixed;
background-repeat: no-repeat;
background-color:#464646;
background-size: cover; }

Upvotes: 1

Related Questions