Search code examples
cssresizecenteralignment

Center CSS Background fit to height


first off here's my current code.

<div id="background">
<img src="src/1080pTux.png" height=100%>
</div>

#background{
    position:fixed;
    margin-left:auto;
    margin-right:auto;
    z-index: -5000;

}

The image stays fit to height, maintains aspect ratio, and stays behind everything, but i want it positioned centered at all times. How can I accomplish that and what am I doing wrong?

Thanks!


Solution

  • You could try somthing like this:

    body {
    text-align: center;
    min-width: 600px;
    }
    

    Even though it says text align it will align the whole page in the center since your modifying the whole body to be centered.