Currently, I am working on a project that requires the use of Bootstrap along with several custom CSS files. In the past, I have been importing Bootstrap's CSS directly into my index.html file using the following code:
<link
href="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="06646969727572746776463328362837">[email protected]</a>/dist/css/bootstrap.min.css"
rel="stylesheet"
integrity="sha384-+0n0xVW2eSR5OomGNYDnhzAbDsOXxcvSN1TPprVMTNDbiYZCxYbOOl7+AMvyTG2x"
crossorigin="anonymous"
/>
However, I now need to import Bootstrap CSS from my node_modules directory. So, I attempted to import it into my index.css file like this:
@import "bootstrap/dist/css/bootstrap.min.css";
This method seems to be "working", but now all of Bootstrap's CSS rules, including its reboots, are overriding my custom CSS (which was not happening before).
Therefore, my main question is: Is there a way to import a local version of Bootstrap's CSS without it conflicting with my custom CSS files?
I came across a potential solution here, but adding a custom body ID to every CSS declaration in my numerous files seems like a laborious task.