简体   繁体   中英

Unable to add bootstrap in angular

Hi I am using using Angular 5 and I am trying to import bootstrap in my code but unable to do so. I have installed bootstrap using:

npm install --save bootstrap

I have also add the css file to the .angular-cli.json as:

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

But when I inspect my code in google chrome what I get is this,

<!doctype html>
<html lang="en">
   <head>
      <meta charset="utf-8">
      <title>MyFirstApp</title>
      <base href="/">
      <meta name="viewport" content="width=device-width, initial-scale=1">
      <link rel="icon" type="image/x-icon" href="favicon.ico">
   </head>
   <body>
      <app-root></app-root>
      <script type="text/javascript" src="inline.bundle.js"></script><script type="text/javascript" src="polyfills.bundle.js"></script><script type="text/javascript" src="styles.bundle.js"></script><script type="text/javascript" src="vendor.bundle.js"></script><script type="text/javascript" src="main.bundle.js"></script>
   </body>
</html>

There is no styles for bootstrap in the header section. Please help me. I am stuck

试试这个,将你的风格bootstrap.min.css添加到style.css

@import "../node_modules/bootstrap/dist/css/bootstrap.min.css";

"./../node_modules/bootstrap/dist/css/bootstrap.css", ./../node_modules/bootstrap/dist/css/bootstrap.min.css",

use same like this

将您的样式bootstrap.min.css添加到style.css main 中:

@import "../src/css/bootstrap.min.css";

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM