在 html 标签上动态设置背景颜色

Dynamically set background-color on html tag

我需要在 html 标签中动态设置背景颜色。

<html style="background-color:{{ backColor }};">

这在 Meteor 中是如何完成的?

如果我理解您的问题,当您调整 window 大小时,您会在页面底部看到白色 space 吗?如果是这样,删除 css 中的 height:100% 将对您有所帮助。

.contentbackground{width:100%;height:100%}

将样式表中的上述内容更改为

.contentbackground{width:100%;}

事实证明解决方案很简单。刚刚将 body 的样式添加到模板的顶部。这似乎不是最佳做法,但它适用于 Chrome 和 Safari。

这似乎也适用于 html 标签。

<template name="spriteBox">
    <style type="text/css">
        body {
            background-color: {{ backColor }}
        }
    </style>
    <!-- rest of content -->
</template>