Home > front end >  Consult everybody a background - attachment: fixed problem
Consult everybody a background - attachment: fixed problem

Time:04-11

I have a div, set wide high is 1024 * 768, background image size is just right for 1024 * 768, when I didn't add background - attachment: fixed; Just fill the div, background chart; And add the background - attachment: fixed, the background becomes width and height are blank,

CodePudding user response:

1, no combined with the former code is such,

 & lt; ! DOCTYPE html> 



<meta charset="utf-8" & gt;


<style>

Div {
Width: 1024 px;
Height: 768 px;
border: 1px solid red;
}
# div1 {
Background - image: url (imgs/which wallpaper - 1. JPG); 1024 x768 *//* background size
Background - repeat: no - repeat;
}

</style>


<body>



Running effect is like this:

CodePudding user response:

2, add the background - attachment: fixed; Style, the background becomes width and height are blank,

CodePudding user response:

Browser f12debugger see may be the div inherited padding
  • Related