admin管理员组文章数量:1335871
I have a blazor page Page.razor
and a css file for that page Page.razor.css
. These files used to be in Components/Pages
but I recently moved them into a subfolder of Pages
. Now blazor generates different css scopes in the css file than for the html elements.
(This only happens when the app is hosted on a server (azure web app in my case). It works fine while I'm running it locally)
This is what's in my HTML document after starting the app:
<div class="chat" b-o6nfzu7aoq>
And this is what's in the css file:
.chat[b-dzcshse1ta] {...}
I've tried rebuilding, checking wether the link to {AppName}.styles.css
in App.razor
exists and creating a new css file for the page.
I have a blazor page Page.razor
and a css file for that page Page.razor.css
. These files used to be in Components/Pages
but I recently moved them into a subfolder of Pages
. Now blazor generates different css scopes in the css file than for the html elements.
(This only happens when the app is hosted on a server (azure web app in my case). It works fine while I'm running it locally)
This is what's in my HTML document after starting the app:
<div class="chat" b-o6nfzu7aoq>
And this is what's in the css file:
.chat[b-dzcshse1ta] {...}
I've tried rebuilding, checking wether the link to {AppName}.styles.css
in App.razor
exists and creating a new css file for the page.
1 Answer
Reset to default 1Now blazor generates different css scopes in the css file than for the html elements.
Using CSS isolation, within the bundled file, each component is associated with a scope identifier. For each styled component, an HTML attribute is appended with the format b-{STRING}
, where the {STRING}
placeholder is a ten-character string generated by the framework.
At build time, a project bundle is created with the convention obj/{CONFIGURATION}/{TARGET FRAMEWORK}/scopedcss/projectbundle/{ASSEMBLY NAME}.bundle.scp.css
.
So, for your issue, you can try the following:
- Delete the
obj
folder and Re-build the application. - Clear the browser cache.
本文标签: cBlazor scoped CSS scopes are not the same as the ones from the HTML elementsStack Overflow
版权声明:本文标题:c# - Blazor scoped CSS scopes are not the same as the ones from the HTML elements - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742372620a2462532.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
.razor
always generates code with the namespace of the folder unless you use the@namespace attribute
. Other than try a clean & rebuild and clear your browsers cache. – Brian Parker Commented Nov 20, 2024 at 23:07