I'm trying to align an image in the center of the screen, but I've run into some trouble. Typically, this is easy by setting the width of a div and using margin: auto;
. However, I also need the div to have the position: fixed;
property, which seems to be causing issues when combined.
Here's the HTML code I'm working with:
<div class="header_container">
<div class="header">
<div class="header_links_icon">
<a href="https://www.facebook.com" target="_blank" class="header_facebook">
<div class="header_facebook_icon"> </div>
</a>
<a href="https://twitter.com/" target="_blank" class="header_facebook">
<div class="header_twitter_icon"> </div>
</a>
</div>
</div>
</div>
Here's the CSS I'm currently using:
.header_container {
background-color: black;
padding-top: 35px;
}
.header {
background-image: url('../images/css/header.png');
background-repeat: no-repeat;
height: 605px;
margin: auto;
width: 1440px;
position: fixed
}
The issue I'm facing is how to successfully align the header.png image in the middle of the screen while maintaining its fixed positioning. Any tips or suggestions would be greatly appreciated!