5

Im doing a web project in Blazor WebAssembly and i want to add a specific CSS file to one of my .razor files but i have no idea on earth how to do it.

The project looks like this. enter image description here

Any one who knows how i add a CSS for ListProducts.razor ?

1

3 Answers 3

11

If you want css file to be specific to one razor file then create css file in same directory with {razor_file_name}.razor.css.

For you case ListProducts.razor.css

info: Microsoft docs

Sign up to request clarification or add additional context in comments.

2 Comments

Yes this is what i was looking for thank you!
I can't understand why this doesn't work for me.
3

Here is a working demo:

My wwwroot folder:

enter image description here

.razor file:

<link rel="stylesheet" href="css/bootstrap/bootstrap1.min.css" />
@code {
   ...
}

result: enter image description here

2 Comments

is that for a individual blazor file ?
Yes,I add it to FetchData.razor to test.
-1

You should already have a premade app.css file located in wwwroot/css/app.css

Add the CSS for your entire app there

1 Comment

I want a css that is specific for one razor file. Not everything.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.