当前位置:Gxlcms > html代码 > 不用HTML/CSS,JS就够了_html/css_WEB-ITnose

不用HTML/CSS,JS就够了_html/css_WEB-ITnose

时间:2021-07-01 10:21:17 帮助过:7人阅读

有人在Github上面建了一个很有意思的项目。你只需要JS就可以创建网页。原理其实很简单,创建一些“html函数”,如: p, div, ul, li 来创建你的网页,而且可以和backbone无缝结合, 下面有个例子:

h1('HTML Creation');p('Tags are functions.')p('Attributes are objects...', {  style:{fontStyle:'italic'}})ul(function(){  li('Nest');  li('with');  li('functions!');});

效果:

HTML Creation

Tags are functions.

Attributes are objects...

  • Nest
  • with
  • functions!

你也用JS来设置些CSS

h1('CSS Creation')css({  '.red':{color:'#e00'},  '.big':{fontSize:'25px'}});div({'class':'red'}, 'This is red');div({c:'big'}, 'This is big');div({c:'big red'}, 'This is both');

效果:

CSS Creation

This is red

This is big

This is both

Github地址: https://github.com/ojjs/oj/

人气教程排行