I am trying to create a fixed background header using the following CSS properties:
header {
margin: 0;
padding: 0;
width: 100%;
height: 300px;
display: block;
background-image: url('...');
background-repeat: no-repeat;
background-size: cover;
background-position: center;
background-attachment: fixed;
}
However, I am facing an issue where the background image is centered based on screen width and height. This results in only the top portion of the image being displayed as the actual background of the header. Additionally, the position of the header image changes whenever the screen height is adjusted, which is not what I intended.
What I want is for the image to be perfectly centered within the header, with the center of the image aligning with the center of the header (without any scrolling). Furthermore, I would like the header image position to adjust only when the header's dimensions or screen width change, without any impact from changes in screen height.