Skip to content

Header image in HTML won't stay in the same position in another computer #21483

Discussion options

You must be logged in to vote

Hello @micaelagimenez,

The problem with absolutely positioned elements, is that, depending on the viewport and parent element, their positions can differ drastically, unless you have a bunch of media queries to correct those positions.

What you’re attempting can be done without relying on position or transform. Here’s a few suggestions:

.header

  • Add center to the background property; this will center the background on all devices.
  • Change margin-right: 340px; to margin-right: auto;, with left and right set to auto, it’ll center the header on all devices.

You could also put the image in the header as an <img> element, then set the max-width on the image to 100% to resize the image on all d…

Replies: 4 comments

Comment options

You must be logged in to vote
0 replies
Answer selected
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants