![](/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.