![](/img/trans.png)
[英]Background-color:rgba() - Safari transparency css bug
[英]Error get-function rgba-css-var is not a valid value for background-color
我已按照以下步骤在 ASPNET Core 项目中设置 Bootstrap 5 SASS。
wwwroot
并选择Add->Client-Side Library
。 选定的 unpkg 提供程序, bootstrap@5.1.3
@5.1.3 库。main.scss
的文件bootsrap
中的 bootsrap 导入以下内容 main.scss
的内容是:
@import "../lib/bootstrap/scss/bootstrap";
Web Compiler->Compile
file,文件编译成功,生成main.min.css
和main.css
<link href="~/css/main.css" rel="stylesheet" />
修改_Layout.cshtml
加载页面时,未正确生成 CSS。 bg-dark
或bg-light
在background-color
中显示无效值。
同样在视觉工作室中,来自同一个文件main.css
的 75 个警告。
我参考了此答案中提到的步骤,发现经过一些更改后它开始工作。
注意:我使用的是 Visual Studio 2022,并且我使用 .net core 6.0 版本创建了一个 Asp.Net 核心项目。
以下是使其工作的步骤。
/wwwroot/lib/bootstrap
文件夹中的文件。WWWroot
文件夹。 单击Add-> Clientside library
选项。bootstrap
并选择choose specific files
选项。 然后检查SCSS
文件夹。 修改目标位置如下。wwwroot/lib/bootstrap/scss
并创建一个名为bootstrap-custom.scss
的文件。 $primary: #00ffff; $white: white; @import "~/lib/bootstrap"; nav.navbar { background: linear-gradient($primary, $white) }
wwwroot/lib/bootstrap/scss
位置并右键单击文件bootstrap-custom.scss
。 选择Web compiler -> Compile file
选项。bootstrap-custom.css
和bootstrap-custom.min.css
文件。 将这两个文件复制到wwwroot/css
文件夹。_Layout.cshtml
文件并添加对bootstrap-custom.css
的引用。 此外,在下面的行中添加注释。注意由您决定将编译后的 CSS 文件保存在哪里。 您只需要确保在布局文件中传递正确的路径。
@*<link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.min.css" />*@ <link href="~/lib/bootstrap/scss/bootstrap-custom.css" rel="stylesheet" /> @*<script src="~/lib/bootstrap/dist/js/bootstrap.bundle.min.js"></script>*@
输出:
注意:您可能需要根据您的环境进行一些更改以使其在您身边工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.