如何在 Blazor 中直接更改 css(不带变量)? [英] How can I change css directly(without variable) in Blazor?

查看:41
本文介绍了如何在 Blazor 中直接更改 css(不带变量)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Blazor 的服务器端.

I am using the server-side of Blazor.

我想更改正文的 CSS.

I want to change the CSS of the body.

在 Jquery 中,我可以轻松地编写这样的代码:

In Jquery I can write the code like this easily:

$("body").css("overflow-y","hidden");

但是,通过本教程(Blazor 更改验证默认 css 类名) 说的,看来只能通过改类名来改CSS了.

However, with this tutorial(Blazor Change Validation default css class names) said, it seems I can only change the CSS by changing the class name.

跨组件的时候太复杂了,尤其是body在所有组件的最上面.

It is so complex while crossing the component, especially the body is at the top of all the components.

不知道有没有办法可以直接在Blazor中更改CSS.谢谢.

I wonder whether there is a way can changes CSS directly in Blazor. Thank you.

推荐答案

好吧,Blazor 尚不支持直接 css 修改,因为 Web Assembly 不支持.不管怎样,它都在 WebAssembly/Blazor 的路线图上.

Well, Blazor does not support direct css modification yet, since Web Assembly doesn't. Anyway heads up, it is on the road-map for Web Assembly/Blazor.

因此,最好的办法是使用变量更改类名.至少现在是这样.

Therefor your best bet is, changing the class name with variables. At least for now.

这篇关于如何在 Blazor 中直接更改 css(不带变量)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆