How to set body margin to 0 in Gatsby and do not die trying
August 02, 2021
1 min.
This is a short and sweet one but might take you a will to realize. Internally Gatsby heavily manipulates the <body/>
tag, so no matter what you do. Classes and styles won't "stick" to it.
First place these older than the web css rules in a file:
src/styles.css
html,body#___gatsby {width: 100%;height: 100%;margin: 0;padding: 0;}
Then create (in case you don't have it already) the following file and import such CSS:
gatsby-browser.js
import "./styles.css"
Enjoy a new world without margins nor paddings!
Latest posts
- How to get your private Ethereum node for cheap
- Improve your SEO by adding a sitemap to your Gatsby MDX blog
- Improve SEO with Microdata on your Gatsby MDX blog
- Fix the infamous "Source file requires different compiler version"
- How to include Javascript files in Gatsby
- How to add tags to your Gatsby MDX Blog