My apologies if this is a stupid question, I'm still pretty new to Vue. I created a Vue (with the command vue init webpack <project-name>
) project and started adding components, the first of which is a navbar. But then I noticed that the body tag has margin: 8px
by default which causes there to always be a 8px white space between my page and the browser on all sides. I can't for the life of me figure out how to get rid of this margin, I've tried using the following css:
* { margin: 0 !important; }
And
body { margin: 0 !important; }
I've tried to add this directly into the root index.html's head in style tags and into all my components' style tags but simply can't get rid of it.
It seems I was an idiot. When I did the *{}
rule in my index's head, I never actually included !important
until I started writing my question, when I didn't remember if the !important
goes before or after the semi-colon. So after I wrote it in my text editor, copied to my question and then carried on I, for some reason, saved my index and what do you know? It worked.
So in conclusion, * { margin: 0 !important; }
in style tags in the index.html's head will do the trick.
Add style for body element in index.html
<style> body { margin: 0 !important; } </style>
example
That's probably because of the "scoped" attribute, remove it in the place where you're setting body margin to 0 and it should work out.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With