js里面修改?
方法1,
xx对象的.className="ground_body"方法2:
xx对象的.style.backgroundSize="567px"
方法1,
xx对象的.className="ground_body"方法2:
xx对象的.style.backgroundSize="567px"
解决方案 »
- 请问json文件在html head中以script的形式导入了,怎样读取这个json对象呢?
- 求助:select中的option的快速选择问题
- 如何用javascript给添加的行赋ID值?
- 怎么监听浏览器关闭事件?
- 请教用thickbox显示多图的问题。
- 脚本绘图??
- 求教!如何使用正则表达式提取网页中的主体内容?
- 看看是否有错,请过管理员
- Gif图片里写JavaScript谁会啊?
- 正确的是如果剩下一个,应该为3,可是这是什么原因呢?怎么才能让他每次都为3呢?
- ~~~~~~~~~~~~~~~~动态添加thead问题,马上给分!~~~~~~~~~~~~~~~~~~~
- 求发一个手机网站用的轮播图,轮播的图可以随屏幕大小改变的。谢谢
.test { width:10px; background-color: red; }
js里面
// 访问 styleSheet 中的一条规则, 将其 backgroundColor 改为蓝色。
var oStyleSheet = document.styleSheets[0];
var oRule = oStyleSheet.rules[0];
oRule.style.backgroundColor = "#0000FF";
<div class="test">aaa</div> 已测试。你可以把color改成size
*{margin:0;padding:0;}
.ground_body{
background-image: url(http://images.csdn.net/20140124/1111.jpg);
background-repeat: no-repeat;
background-position: center;
background-size:87px;
width:100px;
height:100px;
}
</style>
<div id="box" class="ground_body">123213</div>
<script>
function getCurrentStyle(node) {
var style = null;
if(window.getComputedStyle) {
style = window.getComputedStyle(node, null);
}else{
style = node.currentStyle;
}
return style;
}
var oBox = document.getElementById("box");
var obj = getCurrentStyle(oBox);
alert(obj.backgroundSize);setTimeout(function(){
oBox.style.backgroundSize = "120px";
},5000);
</script>