CSS Background Horizontal Center
I have an image as a background with the following CSS setting
#background {
background-image: url('../img/bgimage.jpg');
background-repeat: no-repeat;
background-attachment: fixed;
background-position: center;
opacity: 0.8;
filter:alpha(opacity=80);
top:0;
}
My goal was to center the background (add a bit of opacity), but still start at the top of the page. Now when the user's monitor is too big it looks like
You can see that the image does not start at the top. (gray should be a navigator later, but not interesting in this question). Blue is part of the background, and white is obviously a wildcard until the background maintains the center. How can the image be horizontally centered so that it still starts at the top of the page, or how can the image be resized to fit the user's monitor?
+3
source to share
3 answers
Simple, add the following:
background-position: center center;
background-size: cover;
More info at Perfect Full Page Background Image .
+3
source to share