设置body的div的css有什么简便方法吗?

html-css026

设置body的div的css有什么简便方法吗?,第1张

设置body的div的css,我们是可以直接在<head></head>中添加body{}的css,或者是直接在body那使用style=""这个方法来设置也是一样,如果是想通过JS来改变,那就只要直接doucment.body.style,来设置就行了,举个例子:

<html>

<head>

<style>

body{

width:960px//通过id来控制

height:600px

}

</style>

</head>

<script>

document.body.style.backgroundcolor = "#f00" //通过JS来改变

</script>

<body style="width:900pxheight:400px">

</body>

</html>

body的css规则是:width:100%height:100%background:url(背景地址) no-repeat center centerbackgound-size:100% 100%