使用 ASP.NET Core CSS 隔离时的目标正文标记

问题描述 投票:0回答:1

我正在将“CSS 隔离”与 Razor Pages 结合使用。

我有一个

_Layout.cshtml
_Layout.cshtml.css
。我想给身体应用背景颜色。所以我尝试了
body { background-color: red }

但这会生成带有隔离属性的 css,例如

html body[b-d29f2jaemq] { background-color: red); }
html
body
标签没有此类属性。

有没有办法在CSS隔离文件中定位body标签?

css asp.net-core razor-pages asp.net-core-6.0 asp.net-core-css-isolation
1个回答
1
投票

但这会生成带有隔离属性的 css,例如

html body[b-d29f2jaemq] { background-color: red); }
html
body
标签 没有这样的属性。

有没有办法在CSS隔离文件中定位body标签?

我可以重现这个问题,所以这可能是一个错误或设计使然。我建议您将这个问题发布到 ASP.NET Core GitHub 存储库,然后开发团队会调查它。

作为临时解决方法,您可以尝试将

body { background-color: red }
添加到
wwwroot
文件夹中的 site.css 文件中,并在布局页面中添加此文件引用:

<link rel="stylesheet" href="~/css/site.css" asp-append-version="true" /> 
© www.soinside.com 2019 - 2024. All rights reserved.