You are on page 1of 3

Resumen

Si una imagen de fondo background-image es especificada, background-


attachment determina si la imagen será fija dentro de la pantalla o se desplazará junto al
bloque contenedor.

inicial : desplazamiento (scroll)


Se aplica a: todos los elementos
herencia : no
Porcentajes: N/A
Medio: visual
valor calculada : como se haya especificado

Sintaxis

background-attachment: scroll | fixed | inherit

Valores
scroll
Si scroll es especificado, la imagen de fondo se moverá dentro de la pantalla junto al
bloque que la contiene.

fixed
Si fixed es especificado, la imagen de fondo estará fija en la pantalla y no se moverá con
el bloque contenedor.

Ejemplos

Simple Ejemplo

CSS

p {
background-image: url("https://mdn.mozillademos.org/files/12057/starsolid
background-attachment: fixed;
}

HTML

<p>
There were doors all round the hall, but they were all locked; and when
Alice had been all the way down one side and up the other, trying every
door, she walked sadly down the middle, wondering how she was ever to
get out again.
</p>

Result

Soporta múltiples imagenes de fondo


Esta propiedad soporta multiples imágenes de fondo. Puedes especificar un
diferente <attachment> por cada imagen de fondo, separado por comas. Cada imagen es
asociada con el correspondiente valor de <attachment>, especificado desde el primero hasta el
último.

CSS

p {
background-image: url("https://mdn.mozillademos.org/files/12057/starsolid
background-attachment: fixed, scroll;
background-repeat: no-repeat, repeat-y;
}

HTML

<p>
There were doors all round the hall, but they were all locked; and when
Alice had been all the way down one side and up the other, trying every
door, she walked sadly down the middle, wondering how she was ever to
get out again.

Suddenly she came upon a little three-legged table, all made of solid
glass; there was nothing on it except a tiny golden key, and Alice's
first thought was that it might belong to one of the doors of the hall;
but, alas! either the locks were too large, or the key was too small,
but at any rate it would not open any of them. However, on the second
time round, she came upon a low curtain she had not noticed before, and
behind it was a little door about fifteen inches high: she tried the
little golden key in the lock, and to her great delight it fitted!
</p>

Resultado

Especificaciones
CSS 1
CSS 2.1
CSS 3
Compatibilidad de navegadores

Navegador Versión mínima


Internet Explorer 4
Firefox 1

Netscape 6

Opera

You might also like