propriedade HTML DOM Estilo backgroundImage
estilo Objects
Definição e Uso
backgroundImage conjuntos de propriedades ou retorna os elementos de imagem de fundo.
gramática
Definindo as propriedades backgroundImage:
Object.style.backgroundImage="url('URL')|none|inherit"
Propriedades backgroundImage Voltar:
Object.style.backgroundImage
值 | 描述 |
---|---|
url('URL') | 图像文件的位置。 |
none | 默认。没有背景图像。 |
inherit | background-image 属性的设置从父元素继承。 |
Suporte a navegadores
Todos os principais navegadores suportam backgroundImage propriedade.
Nota: IE7 e versões anteriores não suportam o valor "herdar".IE8 só fornece! DOCTYPE suportado "herdar". suporte IE9 "herdar".
Dicas e Notas
Dica: Além de a imagem de fundo, você também deve especificar uma cor de fundo.Se a imagem não estiver disponível, vamos usar a cor de fundo.
Exemplos
Exemplos
Imagem de fundo:
<! DOCTYPE html>
<Html>
<Head>
<Charset Meta = "utf-8">
<Title> Este tutorial (w3big.com) </ title>
<Script>
displayResult function () {
document.body.style.backgroundColor = "# f3f3f3";
document.body.style.backgroundImage = "url ( 'img_tree.png')";
}
</ Script>
</ Head>
<Body>
<H1> Olá mundo! </ H1>
<br>
<Button type = "button" onclick = "displayResult ()"> definir a imagem de fundo </ button>
</ Body>
</ Html>
<Html>
<Head>
<Charset Meta = "utf-8">
<Title> Este tutorial (w3big.com) </ title>
<Script>
displayResult function () {
document.body.style.backgroundColor = "# f3f3f3";
document.body.style.backgroundImage = "url ( 'img_tree.png')";
}
</ Script>
</ Head>
<Body>
<H1> Olá mundo! </ H1>
<br>
<Button type = "button" onclick = "displayResult ()"> definir a imagem de fundo </ button>
</ Body>
</ Html>
tente »
estilo Objects