Css for svg

<div class="class1">
   <img src="img/svg/facebook.svg" alt="">
   <img src="img/svg/facebook.svg" alt="">
</div>

I was trying to implement this:

.class1 svg {
	width: 50px;
	height: auto;
}

But it doesn’t work. where am I going wrong?

This:

.class1 svg {
  width: 50px;
  height: auto;
}

should be:

.class1 img {
  width: 50px;
  height: auto;
}
3 Likes

Viking-in-chief is a badge of honor or what?

Lol. Ask @fretburner

1 Like

Svgs should expand to fill their parent container unless they have the fixed svg width and height parameters set. Therefore apply the class to the div.

1 Like

The code used the <img> tag, so the size (given in pixels) can (should) be set via the width and height attributes.

3 Likes

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.