Javascript Famo.us和外部CSS样式

Javascript Famo.us和外部CSS样式,javascript,css,famo.us,Javascript,Css,Famo.us,我现在正在浏览famo.us文档,为我的站点创建一个两列网格和页眉页脚 我了解到,样式在JavaScript对象中设置为键值对。我想知道如何仍然保持通过外部样式表设计样式的能力 例如: layout.header.add(new Surface({ size: [undefined, 100], content: "Header", properties: { backgroundColor: 'gray', lineHeight: "10

我现在正在浏览famo.us文档,为我的站点创建一个两列网格和页眉页脚

我了解到,样式在JavaScript对象中设置为键值对。我想知道如何仍然保持通过外部样式表设计样式的能力

例如:

layout.header.add(new Surface({
    size: [undefined, 100],
    content: "Header",
    properties: {
        backgroundColor: 'gray',
        lineHeight: "100px",
        textAlign: "center"
    }
}));
如果我想链接到样式表并在那里设置样式,我可能会说:

layout.header.add(new Surface({
    classes: ['header']
})); 
然后在我的CSS中写:

.header {
    background-color: gray;
    line-height: 100px;
    text-align: center;
}
但是JS对象中还设置了其他属性,比如“size”,我想用它来代替样式表中的“height”和“width”。另外,我想知道我是否可以使用百分比或ems来设计我的应用程序


如果您有任何建议或参考资料,我们将不胜感激。也许没有一种受支持的方法可以做到这一点,因为据我所知,famo.us的目标是抽象出DOM,并在JS中完成所有这些工作。在这种情况下,我想知道如何在famo.us中处理我的项目,使工作流与我习惯的工作流接近。

曲面属性中允许的所有内容都可以放入样式表类中。大小不能是,实际上不想把它放在CSS中。使用famo.us的全部目的是能够通过代码而不是CSS样式表来控制位置、大小和转换。如果您想在代码中动态更改大小,那么有很多方法,比如使用函数而不是固定数组

例如,此代码

new Surface({   content: content,
                size: [100, 100],
                properties: {
                    backgroundColor: "rgb(183, 232, 183)",
                    color: "rgb(51, 51, 51)",
                    fontSize:'10pt',
                    textAlign: 'center',
                    paddingTop:'2pt',
                    border: '1pt solid rgb(135, 192, 140)'
                }
            });
皈依

 new Surface({   content: content,
                size: [100, 100],
                classes:['select-button']
            });
样式表中的css

 .select-button{
                    background-color: rgb(183, 232, 183);
                    color: rgb(51, 51, 51);
                    font-size:10pt;
                    text-align: center;
                    padding-top:2pt;
                    border: 1pt solid rgb(135, 192, 140);
                }

希望这有助于

好的,这有助于我确定Famo.us不是适合我的应用程序的工具。它似乎更倾向于构建UI元素/动画,而不是构建更传统的网站。谢谢你的信息!