$(function(){
})
–>
$(function(){
// 1. 逐个设置,一次只设置一个
// $(“div”).css(“height”, ‘100px’); // 设置div的高度为100
// $(“div”).css(“width”, “100px”); // 设置div的宽度为100
// $(“div”).css(“background”, “red”); // 设置div的背景为红色

// 2. 链式设置
// 注意:链式操作如果大于3布建议分开, 因为可读性就变差了
// $(“div”).css(“height”, ‘200px’).css(“width”, “150px”).css(“background”, “blue”); // 把div设置成高200,宽150,蓝色背景

// 3.批量设置
$(“div”).css({
width: ‘300px’,
height: ‘250px’,
background: ‘pink’,
});

// 4.获取css样式值
let h = $(“div”).css(“height”) // 获取div的高度并赋值给h
$(“div”).text(h) // 把h的值写到div当中
})
