简体   繁体   中英

Shared CSS file blazor

I have 2 pages in my Blazor app working:

Login.razor in the Auth folder

AddPerson.razor in the Profile folder

Now I have a CSS file working for the AddPerson.razor file.

My question is how can I work with the same CSS file for both pages?

文件结构

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. Using the Blazor templates, that would be wwwroot/css/site.css for server side or wwwroot/css/app.css for client side.

Late alternative answer sorry. I have the "Web Compiler" extension installed. You can create a.scss file that imports another handy for definitions etc.

在此处输入图像描述

MessageView.razor.scss

@import "common.scss";

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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