admin管理员组文章数量:1389274
I have this html page on angular:
<div class="main-page-container">
<sidebar-your-chef></sidebar-your-chef>
<div class="content">
<router-outlet></router-outlet>
</div>
</div>
When any of the app's routes are loaded, the styles at startup do not load and for a moment the sidebar is seen without the CSS styles applied. Why don't the styles load initially?
I don't have a global CSS template; instead, each component has its own CSS.
I have this html page on angular:
<div class="main-page-container">
<sidebar-your-chef></sidebar-your-chef>
<div class="content">
<router-outlet></router-outlet>
</div>
</div>
When any of the app's routes are loaded, the styles at startup do not load and for a moment the sidebar is seen without the CSS styles applied. Why don't the styles load initially?
I don't have a global CSS template; instead, each component has its own CSS.
Share Improve this question edited Mar 14 at 20:36 Gerard asked Mar 14 at 20:35 GerardGerard 535 bronze badges1 Answer
Reset to default 0It could be the following reasons.
Network speed is slow, styles taking time to load.
The CSS is large in size so it takes time to download.
You might face this issue only on the DEV server, unless it happens in prod it is not an issue.
Possible Solutions:
- Enable
brotli
orgzip
to compress your website files, which will greatly reduce transfer size and improve loading speeds.
The simple workaround for this, in your app component you can show a loader screen for 1 second to eliminate the flash of no CSS.
@defer() {}@placeholder(minimum 1s) { <app-overlay-spinner/> }
This is a small snippet to show a spinner for 1 second, I know this is not a direct use case of @placeholder
but is a minimal code version to show a spinner for 1 second and then it is gone permanently.
版权声明:本文标题:html - My page does not load the styles correctly when accessing one of its links in Angular - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744633414a2616676.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论