3

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.

3
  • in your style.css stylesheet, add !important after your styles and that will override the bootstrap css for that element. Commented Mar 15, 2016 at 12:25
  • Thanks for your answers. But my problem is still there. Commented Mar 15, 2016 at 13:06
  • hi, I tried all these, but the problem still exists. To be more specific, my container is not occupying full width of the screen, although I've specified margin:0 and padding:0. The container class is not stretching fully to the right side of the screen, even after specifying margin-right:0. I even tried margin-right:-15px.. Still no effect. Please help. I've been stuck with this for soo long. Commented Mar 16, 2016 at 1:20

5 Answers 5

2

Place the Style.css after bootstrap.css For Example : <link href="css/bootstrap.min.css" rel="stylesheet" /> <link href="css/style.css" rel="stylesheet" />

Sign up to request clarification or add additional context in comments.

Comments

1

Create your own custom css file and place it after the bootstrap.css file in bundle config. when the browser renders, the bootstrap renders first and then your custom css renders and overriding the css of bootstrap

Comments

1

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

1

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

If you want more specific help, you will need provide more detail about the issues you are having.
1
  1. Order of the CSS files is important.
  2. Ensure the names of files are a exact match (watch out for caps). For eg, if you have file style.css in 'Content' folder and you enter ~/Content/Style.css, then it will not work. Replace the first capital 'S'.
  3. Ensure to have correct folder name of file in BundleConfig.cs Go to BundleConfig.cs and replace ~/Content/css section with below code:

    bundles.Add(new StyleBundle("~/Content/css").Include(
                  "~/Content/bootstrap.css",
                  "~/Content/Site.css",
                  "~/Content/style.css"));
    

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.