sass 相关问题

Sass(Syntactically Awesome Style Sheets)是CSS的扩展,添加了嵌套规则,变量,mixins和类扩展等功能。这使开发人员能够编写结构化,可管理且可重用的CSS。 Sass被编译成标准CSS。

如何在 Angular 18 和 Material 3 中使用 Roboto 以外的字体

我刚刚开始使用 Angular 3 并解决了错误。 但是,我在尝试让不同的字体和版式正常工作时遇到问题 我刚刚开始使用 Angular 3,并解决了错误。 但是,我在尝试让不同的字体和版式正常工作时遇到问题 <!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <title>StateLineRodz</title> <base href="/"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="preconnect" href="https://fonts.gstatic.com"> <link href="https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500&display=swap" rel="stylesheet"> <link href="https://fonts.googleapis.com/css?family=Muli:400,700" rel="stylesheet"> <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet"> </head> <body class="mat-typography mat-app-background"> <app-component-test></app-component-test> <app-root></app-root> </body> </html> 我的风格.scss @use '@angular/material' as mat; $theme: mat.define-theme( ( color: ( theme-type: light, primary: mat.$blue-palette, tertiary: mat.$magenta-palette, ), ) ); html,body { font-family: Roboto, 'Helvetica Neue', sans-serif; margin: 0; padding: 30px; height: 100%; @include mat.all-component-themes($theme); } :host { display: flex; flex-direction: column; align-items: flex-start; } 角度.json { "$schema": "./node_modules/@angular/cli/lib/config/schema.json", "version": 1, "newProjectRoot": "projects", "projects": { "stateLineRodz": { "projectType": "application", "schematics": { "@schematics/angular:component": { "style": "scss" } }, "root": "", "sourceRoot": "src", "prefix": "app", "architect": { "build": { "builder": "@angular-devkit/build-angular:application", "options": { "outputPath": "dist/state-line-rodz", "index": "src/index.html", "browser": "src/main.ts", "polyfills": [ "zone.js" ], "tsConfig": "tsconfig.app.json", "inlineStyleLanguage": "scss", "assets": [ { "glob": "**/*", "input": "public" } ], "styles": [ "src/styles.scss", "src/m3-theme.scss" ], "scripts": [] }, "configurations": { "production": { "budgets": [ { "type": "initial", "maximumWarning": "500kB", "maximumError": "1MB" }, { "type": "anyComponentStyle", "maximumWarning": "2kB", "maximumError": "4kB" } ], "outputHashing": "all" }, "development": { "optimization": false, "extractLicenses": false, "sourceMap": true } }, "defaultConfiguration": "production" }, "serve": { "builder": "@angular-devkit/build-angular:dev-server", "configurations": { "production": { "buildTarget": "stateLineRodz:build:production" }, "development": { "buildTarget": "stateLineRodz:build:development" } }, "defaultConfiguration": "development" }, "extract-i18n": { "builder": "@angular-devkit/build-angular:extract-i18n" }, "test": { "builder": "@angular-devkit/build-angular:karma", "options": { "polyfills": [ "zone.js", "zone.js/testing" ], "tsConfig": "tsconfig.spec.json", "inlineStyleLanguage": "scss", "assets": [ { "glob": "**/*", "input": "public" } ], "styles": [ "src/styles.scss", "src/m3-theme.scss" ], "scripts": [] } } } } }, "cli": { "analytics": false } } 当我加载页面时,我总是得到相同的字体 我尝试使用不存在的字体加载页面,但没有成功,只需编译并说“确定” 我没有更多线索来猜测这个东西。 首先确保将 font 添加到 index.html。 ... <!-- custom font --> <link rel="preconnect" href="https://fonts.googleapis.com" /> <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin /> <link href="https://fonts.googleapis.com/css2?family=Edu+AU+VIC+WA+NT+Pre:[email protected]&family=Open+Sans:wght@300&display=swap" rel="stylesheet" /> </head> 在此之后,在styles.scss中,您必须首先定义typography-object。有效值为。 _config-validation.scsss $allowed: ( brand-family, plain-family, bold-weight, medium-weight, regular-weight, use-system-variables, system-variables-prefix ); 然后将此定义映射到 define-theme、typography 属性,如下所示。 $theme: mat.define-theme( ( color: ( theme-type: light, primary: mat.$azure-palette, tertiary: mat.$blue-palette, ), typography: $typography-config, // <- notice! ) ); 即使在这些更改之后,您也不会看到正在应用的类型,我们必须调用方法 mat.typography-hierarchy 将版式应用到组件。 @include mat.core(); @include mat.color-variants-backwards-compatibility($theme); @include mat.typography-hierarchy($theme); // <- notice! 完整代码: @use '@angular/material' as mat; $typography-config: ( // <- notice! plain-family: 'Edu AU VIC WA NT Pre', // <- notice! brand-family: 'Edu AU VIC WA NT Pre', // <- notice! ); // <- notice! $theme: mat.define-theme( ( color: ( theme-type: light, primary: mat.$azure-palette, tertiary: mat.$blue-palette, ), typography: $typography-config, // <- notice! ) ); body { font-family: Roboto, 'Helvetica Neue', sans-serif; margin: 0; padding: 30px; height: 100%; @include mat.all-component-themes($theme); } html { height: 100%; } @include mat.core(); @include mat.color-variants-backwards-compatibility($theme); @include mat.typography-hierarchy($theme); // <- notice! Stackblitz 演示

回答 1 投票 0

如何在 Gulp Sass 任务中消除弃用警告 - “旧版 JS API 已弃用,将在 Dart Sass 2.0.0 中删除。”

我当前的安装如下: 节点 - v20.18.0 Gulp - v5.0.0 Gulp-Sass - v5.1.0 Sass - v1.80.6 我的 gulpfile.js: const gulp = require("gulp"); const sass = require("gulp-sass...

回答 1 投票 0

如何制作一个与 CSS 中其他元素交互的固定元素?

我想将图像放置在页面底部,比如说顶部:70%。无论上面添加多少元素,图像都不应该受到它们的影响。图像应该只是...

回答 1 投票 0

如何在角度中设置 ngx-bootstrap 组件的样式?

我想更改导航链接样式 这是我在 my.component.scss 中的尝试 标签集{ 一个{ .nav-链接{ 背景:#FFFFFF; 边框:1px实线#DDE6FB; 边界-...

回答 3 投票 0

如何在SCSS中使用CSS round(),它也有round?

有人在SCSS中使用我的CSS库,当我使用round()时,它给出了这个错误。 jquery.terminal.css:850:22": 参数 $number of round($number) 必须是一个数字 根据 MDN 轮次在

回答 1 投票 0

Webpack sass-loader 未生成正确的源映射

我有一个包含 sass-loader 的 webpack 配置。当我删除 sass-loader 时,我可以看到正确生成的源映射。但是当我添加 sass-loader 后源映射就被破坏了。 入口: { ...

回答 1 投票 0

此浏览器不支持Webpack5自动publicPath

我正在使用 webpack 4.44.2,当我转换到 webpack5.0.0 时遇到这个错误 ./src/assets/sass/styles.scss 中出现错误 模块构建失败(来自 ./node_modules/mini-css-extract-plugin/dist/loader...

回答 0 投票 0

无法弄清楚为什么@Angular/Material datepicker中缺少某些样式

我们有一个 Web 应用程序,正在从 Angular v16 更新到 v18。 99% 的东西看起来不错并且工作得很好,但我有一个问题我无法弄清楚,那就是日期 p 的样式...

回答 1 投票 0

Sass 1.8 从 @import 迁移破坏了 mixins

我正在尝试迁移我的 scss 代码以适应 1.8。 Migrator 工具没有帮助 错误:未定义的混合。 ╷ 12 │ @include 机器人(700); style.scss(根) @使用“字体”; @use 'mixins...

回答 1 投票 0

找不到模块:错误:无法使用 Webpack 解析“fs”

嗨,我在我的应用程序中使用套接字 io。这需要fs。当我尝试使用下面的 webpack 配置捆绑我的 javascript 时。我收到错误无法解析“fs”。 找不到模块:错误:不能

回答 4 投票 0

需要帮助生成 bootstrap 5 实用程序

我在一家想要创建自己的实用程序类的公司工作,我必须创建设置才能使其工作。 这是相关详细信息的列表 所有这些进口都是公司的...

回答 1 投票 0

如何在Quasar中的q-stepper组件中自定义done-color、active-color和inactive-color?

我正在使用 Quasar 中的 q-stepper 组件,并且想为步骤的每个状态自定义颜色:完成颜色、活动颜色和非活动颜色。 我遇到过这个问题,不是...

回答 1 投票 0

在 SCSS @mixin 中调用 @include 时如何传递关键字参数?

我有一个 SCSS 文件,它定义了一个“子”mixin,它被其他文件中的几个“父”mixin 包含。父和子 mixin 都使用默认的可选关键字参数

回答 1 投票 0

为什么嵌套 SCSS 导入在生产中失败但在开发中有效?

我正在与 React 项目中棘手的 SCSS 导入情况作斗争,这让我失去了理智。 问题 我的 SCSS 导入在开发中完美运行,但是当我为生产构建时,它...

回答 1 投票 0

NextJS 15.0.2 - 编译失败

我将 nextJS 网站升级到 15.0.2 但出现此错误: 创建优化的生产构建... 编译失败。 ./src/app/[语言环境]/path/file.module.scss _0_0.call$1 不是函数 ...

回答 1 投票 0

使用 Dart Sass 时如何解决弃用警告“旧版 JS API 已弃用”?

我在 js 中构建项目时收到以下消息,但 Dart Sass 已经是最新的了。在这种情况下我该怎么办? [@localhost 前端]$ npm run lumis:build .../前端/

回答 1 投票 0

更改 Angular 中切换按钮的颜色

我无法更改 Angular 中切换按钮的颜色。 这是我的代码: 切换 ::ng-deep .custom-toggl...

回答 1 投票 0

如何在多个文件之间共享 SASS 变量而不使用已弃用的 @import 规则?

tl;dr:有没有办法在多个文件之间共享一组全局变量,而无需手动将它们导入到每个文件中,并且无需使用 @import 规则? 我曾经用过 @import 一分钱......

回答 2 投票 0

Angular 17 - 找不到要导入的样式表(Angular 升级后)

我已经找到了与角度材料主题相关的所有内容,但是,事实并非如此。 Angular 16 升级到 Angular 17 后,我无法从特定的 node_module 导入某些样式。 HookWebpackE...

回答 1 投票 0

将成帧器运动与 Preact 一起使用时,属性“className”不存在

任何人都可以解释为什么我不能在framer-motion中使用className或onClick: 从'framer-motion'导入{motion}; 导出函数 App() { 返回应用程序...

回答 1 投票 0

最新问题
© www.soinside.com 2019 - 2025. All rights reserved.