欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  web前端

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

程序员文章站 2022-05-30 21:46:11
...
有人在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/