1.div居中
<!--div居中,要设置margin值margin:0 auto;-->
<div style="text-align: center;width:500px;margin:0 auto;padding:0;" align="cneter">
<input type="button" value="变宽"/>
<input type="button" value="变高"/>
<input type="button" value="变色"/>
<input type="button" value="隐藏"/>
<input type="button" value="重置"/>
<div style="background: black;height:100px;width: 100px;margin:10px auto;display: block;">
</div>
</div>
2.JS问题
case “.”:在case "=“之前,会执行case”="的语句
offsetWidth\offsetleft 等图文解释 :
http://blog.sina.com.cn/s/blog_63426ff90100m8c3.html
得到CSS样式
switch (arguments.length){
case 2:
if(typeof arguments[1] == "object"){
//二个参数, 如果第二个参数是对象, 批量设置属性
for (var i in attr)obj.style[i] = attr[i];
}
else{
//二个参数, 如果第二个参数是字符串, 读取属性值
//全局方法getComputedStyle,获取当前对象样式信息
return obj.currentStyle ? obj.currentStyle[attr] : getComputedStyle(obj, null)[attr];
}
break;
case 3:
//三个参数, 单一设置属性
obj.style[attr] = value;
break;
default:
alert("参数错误!")
}