Для вашего CSS, убедитесь, что он находится в вашем _Host.cs html файле
<link href="css/site.css" rel="stylesheet" />
Эта строка работает, если у вас есть файл CSS под wwwroot/CSS/site.css, который является по умолчанию для нового проекта Blazor.
![enter image description here](https://i.stack.imgur.com/435yL.png)
If you have a difference CSS file, you can drag it from Solution Explorer to the _Host.cshtml file and Visual Studio adds the link for you.
Not that you need to know this, but you can also reference CSS in a Nuget package like this:
I use BlazorStyled a lot because you can dynamically change CSS values:
I have an open source project that uses BlazorStyled Nuget package.
Code is here if you want a working example:
https://github.com/DataJuggler/BlazorChat
Пример использования BlazorStyled
<Styled @bind-Classname="@BubbleStyle">
background-image: url('@ImageUrl');
background-repeat: no-repeat;
background-size: 100% 100%;
position: relative;
left: 0%;
top: 0vh;
width: 84%;
height: auto;
margin-bottom: 1.2vh;
</Styled>
В приведенном выше примере @BubbleStyle - это просто строковое свойство в моем компоненте.
Свойство @ImageUrl изменяется для каждого сообщения чата, где я показываю один из этих пузырей:
![enter image description here](https://i.stack.imgur.com/UbTdV.png)
Site is also live, but not many people have signed up yet:
https://blazorchat.com