Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.7k views
in Technique[技术] by (71.8m points)

html - set background image in blazor webassembly

I tried to set background image for my div with codes below:

background-image: url(../wwwroot/resources/images/LoginBackground.jpg);

but it doesn't work, I try ' and " in url but it doesn't work also.

question from:https://stackoverflow.com/questions/65917673/set-background-image-in-blazor-webassembly

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

This path is the relative path after compilation, you can use <img > to judge.

<img src="./resources/images/LoginBackground.jpg"/>

If it can show the image, this path can be assigned to url().

background-image:url('./resources/images/LoginBackground.jpg')

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...