If you're looking to dive deeper into CSS specificity, I highly recommend checking out the documentation on the topic at
CSS Specificity: Mozilla Developers. I also provide some insights below.
When it comes to overriding CSS properties from external libraries, there are a few different approaches you can take.
Solution 1: If you're utilizing Bootstrap or Zurb Foundation through an npm package, you can adjust a variable value that controls the property you want to change. Make sure to do this after importing all the necessary library files for the changes to take effect. Here's an example:
import 'files from library.sass';
// my settings
$default-width: 80%;
Solution 2: If you're using a CDN to serve your library, you can use a more specific CSS selector to override the desired property. For instance:
To override a div selector:
div {} ----> div.my-class {}
Another technique, although not recommended, is to use the !important
declaration. However, be cautious as this can lead to complications during development. It's generally advised to opt for a more specific selector instead of relying on !important
.