CJSS基于 CSS 的 Web 框架
CJSS 是一個基于 CSS 的 Web 框架,所有效果都在 CSS 文件中生效,可以在 CSS 中使用它添加更多功能,或者構(gòu)建一個完整的頁面。
使用方法:
HTML
想要使用某個組件,在 CSS 文件中選擇它,然后添加 --html:(your markup here);
h1 {
--html:(
This is a headline
);
}
如果希望通過標(biāo)簽產(chǎn)生效果,如下
<component>My Component</component>
component {
--html:(
<h2>${yield}</h2>
<p>This is a component</p>
);
}
就會呈現(xiàn)為
<component> <h2>My Component</h2> <p>This is a component</p> </component>
JavaScript
如果想使用 JavaScript 從 HTML 中直接定義事物的行為,在 CSS 文件中就可以執(zhí)行此操作。
.item {
cursor: pointer;
--js:(
function toggle() {
this.classList.toggle('active');
}
this.addEventListener('click', toggle );
);
}
添加數(shù)據(jù)方法
使用 --data(key:[data]) 屬性
nav {
--data:(
name: ['one', 'two', 'three'],
link: ['#one', '#two', '#three'],
);
--html:(
<a class="item" href="${data.link[0]}">${data.name[0]}</a>
<a class="item" href="${data.link[1]}">${data.name[1]}</a>
<a class="item" href="${data.link[2]}">${data.name[2]}</a>
);
--js:(console.log(data));
}
框架案例
評論
圖片
表情
