admin管理员组文章数量:1278721
I have a page, served with Nuxt SSR. It has a header with position:fixed and content that will have a padding-top that equals the header's height:
.content {
padding-top: var(--header-height);
}
Before I switched to using SSR I simply set the custom CSS var in the onMounted hook of the header component. This would come too late now, since the content will already be rendered before the Vue app mounts (SSR).
Is there an elegant way to set the custom CSS variable --header-height
(i.e. on the <html>
tag) before the page content is rendered? Could I somehow do the following?
- Retrieve the header height server-side
- Inject a script to the document's head that sets the variable on the
<html>
element, using the value from 1.
本文标签: vuejs3Nuxt Set custom CSS Var asapdepending on height of elementStack Overflow
版权声明:本文标题:vuejs3 - Nuxt: Set custom CSS Var asap, depending on height of element - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741303592a2371237.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论