简体   繁体   English

共享 CSS 文件 blazor

[英]Shared CSS file blazor

I have 2 pages in my Blazor app working:我的 Blazor 应用程序中有 2 页工作:

Login.razor in the Auth folder Auth文件夹中的Login.razor

AddPerson.razor in the Profile folder配置文件文件夹中的AddPerson.razor

Now I have a CSS file working for the AddPerson.razor file.现在我有一个适用于 AddPerson.razor 文件的 CSS 文件。

My question is how can I work with the same CSS file for both pages?我的问题是如何为两个页面使用相同的 CSS 文件?

文件结构

The strengths of the new .NET5 CSS isolation feature (placing a css file "below" your razor file), is that the css is NOT shared between pages/components making them easier to develop and contained/bundled to the specific component. The strengths of the new .NET5 CSS isolation feature (placing a css file "below" your razor file), is that the css is NOT shared between pages/components making them easier to develop and contained/bundled to the specific component.

If you however want to add some shared css that would be available thru out your app, you would do it "the old fashion way" by editing the site-wide css file.但是,如果您想添加一些可通过您的应用程序使用的共享 css,您可以通过编辑站点范围的 css 文件来“以旧方式”进行操作。 Using the Blazor templates, that would be wwwroot/css/site.css for server side or wwwroot/css/app.css for client side.使用 Blazor 模板,即wwwroot/css/site.css用于服务器端或wwwroot/css/app.css用于客户端。

Late alternative answer sorry.迟到的替代答案对不起。 I have the "Web Compiler" extension installed.我安装了“Web 编译器”扩展。 You can create a.scss file that imports another handy for definitions etc.您可以创建一个.scss 文件,该文件导入另一个方便的定义等。

在此处输入图像描述

MessageView.razor.scss

@import "common.scss";

.bubble {
    border-radius: 5px;
    box-shadow: $bubbleShadow; 
...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM