M trying to build a website using Mvc asp.net in Visual Studio 2013. I've bundled my css file-'style.css' to the project, but my website has undesirable white spaces and margins around headers and other important elements, in spite of setting margin:0 in my css. I found that the bootsrap.css file that is in the project by default is causing this. How do i override the bootstrap.css file? Because it is for main elements like header and container, being specific does not help. M a beginner in this. Please help me with a solution.
5 Answers
You could add the "!important" tag to your style items if you see that your attributes are not taken into account.
https://css-tricks.com/when-using-important-is-the-right-choice/
Comments
Place the <link /> element for your style.css after the bootstrap element. The styles are applied in order, so your style.css file will be applied over the bootstrap styles.
1 Comment
James Gardner
If you want more specific help, you will need provide more detail about the issues you are having.
- Order of the CSS files is important.
- Ensure the names of files are a exact match (watch out for caps). For eg, if you have file
style.cssin 'Content' folder and you enter~/Content/Style.css, then it will not work. Replace the first capital 'S'. Ensure to have correct folder name of file in
BundleConfig.csGo toBundleConfig.csand replace~/Content/csssection with below code:bundles.Add(new StyleBundle("~/Content/css").Include( "~/Content/bootstrap.css", "~/Content/Site.css", "~/Content/style.css"));
style.cssstylesheet, add!importantafter your styles and that will override the bootstrap css for that element.