I am failing to see why I can't get my background image to be positioned center center.
Help?
Set background-position: 50% 50%
and set the height: 100%
on the html
element. The height is essential, otherwise, the background gets centered in the wrong space.
You have to set the height of the html
element to 100%
in order to get your code to work. Currently, your body has an offset height of 0px.
html, body {
height: 100%;
}
To future readers: To center a background, use:
background-position: center center;
To keep the background at the same position when a user scrolls, use:
background-attachment: fixed;
See this page for a full reference.
精彩评论