That means its positioned relative to its nearest positioned ancestor which in this case is the image. Set the containers position relative to its normal position and define its width and height. Center An Element Css Cascading Style Sheets Mdn Center A Div With Pure Css Digital Inspiration Julia Evans On Twitter Centering In Css