The img element should responsively resize, relative to the width of its parent element, without exceeding its original size.
That made me think of the relative position.
Also here is a great tutorial for making css images which uses this same technique for centering a div:
//optional background or border
border: solid 4px red;
//add more code here
Position relative means the element is positioned relative to its normal position, which would be the very top left corner as it is the first div in the body.
When the position is set to relative, using display: block; and margin:auto; will automatically center the box horizontally.
I’ve edited your post for readability. When you enter a code block into the forum, precede it with a line of three backticks and follow it with a line of three backticks to make easier to read. See this post to find the backtick on your keyboard. The “preformatted text” tool in the editor (</>) will also add backticks around text.