一、css()
参数可以为 属性名;数组;key-value;对象
- 返回一个css属性值
$(‘div’).css(‘class’); - 返回多个css属性
$(‘div’).css([‘class’,‘id’,‘background’]); - 设置一个css属性
$(‘div’).css(‘width’,‘200’); // 200 ‘200’ ‘200px’ 皆可 - 设置多个css属性
$(‘div’).css({
‘class’: ‘myDiv’,
‘width’: ‘+=100’, //在当前基础上加100px
‘background-color’: red
});
二、width(),inner Width(),outer Width()
height 的同理
$(‘div’).width(200); === $(‘div’).css(‘width’,200);
width() === content
innerWidth() === content + padding
outerWidth() === content + padding + border
outerWidth(true) === content + padding + border + margin
- 使用innerWidth()、outerWidth()改变宽度时,
只改变content区的,不改变padding、border、margin