Centre an SVG in a Div

Glenn Blog Leave a Comment

To centre an SVG in a div simply change its default ‘inline’ display to ‘block’ and then give it a margin of auto, so: –

.svg-class {
  display: block;
  margin: auto;
}

Still not centring, then give your SVG a ‘width’ property e.g. width: 200px;

About the Author
centre an svg in a div Centre an SVG in a Div 0da77002febbfe28d15144a57bbcc2c9 s 180 d mm r g

Glenn

A highly experienced Web Designer / Web Developer (Webflow, WordPress, Weebly & Custom), Front-end / Back-end Developer & New Media Specialist, with extensive knowledge of a wide spectrum of technologies in the Development and Creative Industries, built up over a number of years.