简体   繁体   English

css 不从 .scss 文件中获取 css

[英]css not taking css from .scss file

Not sure what am I missing...不知道我错过了什么......

I did try with css and scss and different combinations in .scss file.我确实尝试过使用 css 和 scss 以及 .scss 文件中的不同组合。 Still I don't see(in Inspect Element) it is taking the css from bootstrap.我仍然没有看到(在 Inspect Element 中)它正在从引导程序中获取 css。

Yes, I do have bootstrap css and scss files in the corresponding path.是的,我确实在相应的路径中有引导 css 和 scss 文件。

angular.json angular.json

   "styles": [
      "src/styles.scss",
      "node_modules/bootstrap/scss/bootstrap.scss",
      "node_modules/bootstrap/dist/css/bootstrap.min.css",
      "node_modules/font-awesome/css/font-awesome.min.css"
    ],
    "scripts": [
      "node_modules/jquery/dist/jquery.min.js",
      "node_modules/bootstrap/dist/js/bootstrap.min.js"
    ]

styles.scss样式.scss

@import '~bootstrap/scss/bootstrap';
@import "~bootstrap/scss/functions";
@import "~bootstrap/scss/variables";
@import "~bootstrap/scss/mixins";
@import "~bootstrap/scss/grid";
@import "~bootstrap/scss/navbar";
@import "~bootstrap/scss/forms";
@import '~bootstrap/scss/bootstrap.scss';

@import "styles-variables.scss";
@import "~@angular/material/prebuilt-themes/indigo-pink.css";
@import "~ng-pick-datetime/assets/style/picker.min.css";

在此处输入图片说明

My Other App looks fine我的其他应用看起来不错在此处输入图片说明

somemore information, if that can give any clue.更多信息,如果可以提供任何线索。 Not sure if it is because of mat-side-nav不确定是不是因为 mat-side-nav 在此处输入图片说明

You shouldn't need to import these line of code您不需要导入这些代码行

@import '~bootstrap/scss/bootstrap';
@import "~bootstrap/scss/functions";
@import "~bootstrap/scss/variables";
@import "~bootstrap/scss/mixins";
@import "~bootstrap/scss/grid";
@import "~bootstrap/scss/navbar";
@import "~bootstrap/scss/forms";
@import '~bootstrap/scss/bootstrap.scss';

Since you already include the css file in your angular.json.由于您已经在 angular.json 中包含了 css 文件。 With your current code you will have redundant code使用您当前的代码,您将拥有冗余代码

To use Bootstrap styles in your application you need:要在您的应用程序中使用Bootstrap样式,您需要:

  1. At first, you need to install Bootstrap: npm install –save bootstrap首先需要安装Bootstrap: npm install –save bootstrap

  2. You should add import in styles.scss :您应该在styles.scss添加导入:

     @import "~bootstrap/dist/css/bootstrap.css";
  3. Add into angular.json file declaration of styles:angular.json文件中添加样式声明:

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

The styles are actually coming from the bootstrap.min.css, but you're browser inspector is showing the SASS source map.该风格实际上从bootstrap.min.css到来,但你的浏览器检查器显示SASS源地图。

Learn more: why inspections showing scss file instead of bootstrap.css?了解更多: 为什么检查显示 scss 文件而不是 bootstrap.css?

Learn how to disable the SASS map in the inpsection tools: Disable source maps in Chrome DevTools了解如何在 inpsection 工具中禁用SASS 地图: 在 Chrome DevTools 中禁用源地图

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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