批量设置样式json版
2015-09-08 17:46
603 查看
<!doctype html> <html> <head> <meta charset="utf-8"> <meta name="author" content="智能社 - zhinengshe.com"> <meta name="copyright" content="智能社 - zhinengshe.com"> <title>智能社 - www.zhinengshe.com</title> <style> #div1 { width:200px; height:200px; border:5px solid red; } </style> <script> window.onload=function (){ var oDiv=document.getElementById('div1'); setStyle(oDiv, { 'width' : '500px', 'height': '500px', 'border':'20px solid blue' }); }; function setStyle(obj, json) { for (var i in json) { obj.style[i]=json[i]; } } </script> </head> <body> <div id="div1"></div> </body> </html>
相关文章推荐
- css 文字换行
- 18. CSS 内边距
- Grunt 单独对css压缩并生成min.css文件
- CSS 最核心的几个概念
- CSS——(2)与标准流盒模型
- 实例讲解使用CSS实现多边框和透明边框的方法
- CSS实现三角形的动画旋转
- html常用样式
- css省略号布局实例截图
- CSS 最核心的几个概念
- CSS属性书写规范
- 自定义checkbox样式
- getComputedStyle与currentStyle获取样式(style/class)
- CSS-3 圆角Border-radius 的使用
- css日常知识总结
- 伪元素表单控件默认样式重置与自定义大全
- CSS布局奇淫技巧之--各种居中<转>
- CSS3: transition实例
- CSS3: transition实例
- css3扇形菜单