Propriedade de anexo de fundo de estilo
Exemplo
Defina uma imagem de fundo a ser corrigida (não rolará):
document.body.style.backgroundAttachment = "fixed";
Mais exemplos de "Experimente você mesmo" abaixo.
Definição e uso
A propriedade backgroundAttachment define ou retorna se uma imagem de plano de fundo deve rolar com o conteúdo ou ser corrigida.
Suporte ao navegador
Os números na tabela especificam a primeira versão do navegador que oferece suporte total à propriedade.
Property | |||||
---|---|---|---|---|---|
backgroundAttachment | 1.0 | 4.0 | 1.0 | 1.0 | 3.5 |
Sintaxe
Retorne a propriedade backgroundAttachment:
object.style.backgroundAttachment
Defina a propriedade backgroundAttachment:
object.style.backgroundAttachment = "scroll|fixed|local|initial|inherit"
Valores de propriedade
Value | Description |
---|---|
scroll | The background scrolls along with the element. This is default |
fixed | The background is fixed with regard to the viewport |
local | The background scrolls along with the element's contents |
initial | Sets this property to its default value. Read about initial |
inherit | Inherits this property from its parent element. Read about inherit |
Detalhes técnicos
Valor padrão: | rolagem |
---|---|
Valor de retorno: | Uma String, representando como a imagem de fundo é anexada ao objeto dentro do documento |
Versão CSS | CSS1 |
Mais exemplos
Exemplo
Escolha entre rolagem e local em um elemento DIV:
document.getElementById("myDIV").style.backgroundAttachment = "local";
Exemplo
Alternar entre rolagem e fixo:
var x = document.body.style.backgroundAttachment;
document.body.style.backgroundAttachment = (x == "scroll")? "fixed":"scroll";
Exemplo
Retorne o valor da propriedade background-attachment:
alert(document.body.style.backgroundAttachment);
Páginas relacionadas
Tutorial de CSS: Fundo de CSS
Referência CSS: propriedade background-attachment
Referência HTML DOM: propriedade background