Background – attachment properties

Determines whether the position of the background image is fixed in the mouth or scrolls along with the block containing it.

background-attachment : scroll |fixed | local

Scroll: default value for background image to scroll with external scroll bar but not with internal scroll bar

Fixed Background image does not scroll with external scroll bar, nor does it scroll with internal scroll bar

Local: The internal scroll bar moves and the external scroll bar moves

Case presentation

<! DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta Name ="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> } .box { width:200px; height:200px; border: 1px solid #000; /* overflow-y:scroll; background-image:url("logo.png"); / /* Background-attachment :fixed; / /* Background-attachment :scroll; / / background-attachment:scroll; */ attachment:local; background-attachment:local; } < / style > < / head > < body > < div class = "box" > < / p > < p > content content < / p > < p > < p > content < / p > < p > content < / p > < p > content < / p > < p > content < / p > < / p > < p > content Content < / p > < p > < p > content < / p > < p > content < / p > < p > content < / p > < p > content < / p > < p > content < / p > < p > content < / p > < p > content < / p > < p > content < / p > < p > content < / p > < p > content < / p > < / p > < p > content Content of the < p > < / p > < p > content < / p > < p > content < / p > < p > content < / p > < p > content < / p > < p > content < / p > < / div > < / body > < / HTML >Copy the code