user1968859
user1968859

Reputation: 23

Why isn't SVG showing by css background-image

I am able to get an svg to show just fine when I use

<img src="../images/jte.svg" alt="Logo">

however, when I try and display via css using the following:

html

<div class="logo2">
</div>

css

.logo2 {
background-image: url(jte.svg);
}

Nothing is being displayed. Any idea why this is happening? I have tried multiple different path options "('../images/jte.svg') ('jte.svg) no avail though.

Upvotes: 1

Views: 3664

Answers (1)

Paul Sweatte
Paul Sweatte

Reputation: 24617

Use a defined width and height for the element in question, or simply attach it to the body. For example:

body { background-image: url('https://cdn.sstatic.net/Sites/stackoverflow/img/sprites.svg')

Upvotes: 1

Related Questions