Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bootstrap styles not applying to my angular 2 project

I added bootstrap css in angular-cli.json - styles. Not applying bootstrap styles to my project. I added in package.json and did npm install. How to resolve this?

angular-cli.json

        "styles": [
            "styles.css",
            "../node_modules/bootstrap/dist/css/bootstrap.css"
        ]

package.json

 "dependencies": {
    "bootstrap": "^4.0.0-beta.2"
 }
like image 806
Veera Avatar asked Dec 20 '17 10:12

Veera


People also ask

What to do if bootstrap is not working in Angular?

If you are adding the bootstrap path into the angular. json file, make sure it is the styles within the project\architect\build. Not the one in the project\architect\test.

Why is bootstrap not working?

These are the possible reasons: You have a wrong or incorrect link to the bootstrap file. browser caching and history is messing with your html. Other CSS files are overriding the bootstrap file.


2 Answers

  1. No need to update or reinstall your bootstrap just do below mentioned step it will work for you

  2. open angular-cli.json inside styles array and specifying the path of bootstrap like this:

    Angular-cli.json:

    "styles": [
        "./node_modules/bootstrap/dist/css/bootstrap.min.css",
        "styles.css"
    ],
    
  3. Open your style.css and paste this at the top:

    @import url("../node_modules/bootstrap/dist/css/bootstrap.min.css")    
    
like image 85
Gaurav Joshi Avatar answered Jan 12 '23 17:01

Gaurav Joshi


In your style.css add following line of code on top and let us know.

@import url("../node_modules/bootstrap/dist/css/bootstrap.min.css")

Also check with following line too

@import url("./node_modules/bootstrap/dist/css/bootstrap.min.css")

Hope it will help.

like image 20
Sandip Jaiswal Avatar answered Jan 12 '23 16:01

Sandip Jaiswal