📅  最后修改于: 2023-12-03 15:30:32.794000             🧑  作者: Mango
The document.body.style.background
property is a JavaScript property used to set the background color or image of the body element of an HTML page. This property works together with other CSS styles that can be applied to the body element.
document.body.style.background = "value";
value
can be any valid CSS background property value, such as a color name, hex code, RGB value, or image URL.// set background color to blue
document.body.style.background = "blue";
// set background image
document.body.style.background = "url('image.jpg')";
// set background color and image
document.body.style.background = "rgb(120, 120, 120) url('image.jpg')";
url()
function to reference an image file.The document.body.style.background
property can be used in many ways, such as:
In conclusion, the document.body.style.background
property is a versatile and useful property in JavaScript that allows developers to set the background color or image of the body element of an HTML page. Its flexibility makes it a powerful tool for creating visually appealing and dynamic web pages.