SVG is inline by default. Add display: block
to it and then margin: auto
will work as expected.
More Related Contents:
- CSS: clean solution to the margin collapse issue when floating an element
- When to use margin vs padding in CSS [closed]
- Transparent text cut out of background
- SVG data image not working as a background-image in a pseudo element
- Make div stay at bottom of page’s content all the time even when there are scrollbars
- Margin-Top not working for span element?
- CSS transition effect makes image blurry / moves image 1px, in Chrome?
- Why does order of transforms matter? rotate/scale doesn’t give the same result as scale/rotate
- How to prevent long words from breaking my div?
- CSS transparent curved shape with two rounded sides
- CSS: Margin-top when parent’s got no border
- Scrolling a flexbox with overflowing content
- Is there a way to use SVG as content in a pseudo element ::before or ::after
- How to animate handwriting text on the web page using SVG?
- How to style a div to be a responsive square? [duplicate]
- Specify an SVG as a background image and ALSO style the SVG in CSS?
- Can I change the fill color of an svg path with CSS?
- Difference between static and relative positioning
- html, css – weird invisible margin below pictures
- SVG in img element proportions not respected in ie9
- Deprecated SMIL SVG animation replaced with CSS or Web animations effects (hover, click)
- CSS: fixed to bottom and centered
- Set position absolute and margin
- Remove “whitespace” between div element
- How to get these two divs side-by-side?
- How can I change the color of an ‘svg’ element?
- Transparent hollow or cut out shape in HTML
- CSS change d property of
- Fill only Half a star with SVG
- Using SVG as background image