Style backgroundAttachment attribute
- Σελίδα Προηγούμενη background
- Σελίδα Επόμενη backgroundColor
- Επιστροφή στο Πάνω επίπεδο Όντοτητα Style HTML DOM
Definition and usage
backgroundAttachment
Property settings or returns whether the background image should scroll with the content or be fixed.
See also:
HTML Styles:background attribute
CSS Tutorial:Πίσω από το CSS
CSS Reference Manual:background-attachment attribute
Instance
Example 1
Set the background image to fixed (does not scroll):
document.body.style.backgroundAttachment = "fixed";
Example 2
Select scroll and local on the DIV element:
document.getElementById("myDIV").style.backgroundAttachment = "local";
Example 3
Toggle between scroll and fixed:
var x = document.body.style.backgroundAttachment; document.body.style.backgroundAttachment = (x == "scroll")? "fixed":"scroll";
Example 4
Return the value of the background-attachment attribute:
alert(document.body.style.backgroundAttachment);
Syntax
Return the backgroundAttachment attribute:
object.style.backgroundAttachment
Set the backgroundAttachment attribute:
object.style.backgroundAttachment = "scroll|fixed|local|initial|inherit"
Attribute value
Value | Description |
---|---|
scroll | The background scrolls with the element. Default. |
fixed | The background is fixed relative to the viewport. |
local | The background scrolls with the content of the element. |
initial | Set this property to its default value. See initial. |
inherit | Inherit this property from its parent element. See inherit. |
Technical details
Default value: | scroll |
---|---|
Return value: | A string that indicates how the background image is attached to the objects in the document. |
CSS version: | CSS1 |
Browser support
backgroundAttachment
It is a feature of CSS1 (1996).
All browsers fully support it:
Chrome | Edge | Firefox | Safari | Opera | IE |
---|---|---|---|---|---|
Chrome | Edge | Firefox | Safari | Opera | IE |
Υποστήριξη | Υποστήριξη | Υποστήριξη | Υποστήριξη | Υποστήριξη | Υποστήριξη |
- Σελίδα Προηγούμενη background
- Σελίδα Επόμενη backgroundColor
- Επιστροφή στο Πάνω επίπεδο Όντοτητα Style HTML DOM