我正在将“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,例如
。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" />