Hi everyone, I need to position image on the left site of the header and vertical separating line , so I haven’t found anything better than applying “-131” margin to “Uber Mich” paragraph, I am not sure it is a good tone in css, even though it works perfectly, what is the better way to do it? Thanks
Negative values aren’t to avoid. It doesn’t mean your code is dirty.
However, negative values to position horizontally can almost always be avoided in favor or something simpler, more solid, easier to maintain, more “elastic” (which means it will behave nicely across breakpoints without too much static parameters.
I see you got rid of the negative values, is your issue solved then?
Generally speaking, when you’re facing this situation where you’ll have several elements overlapping, that need a specific, controlled position, you’re going to rely on absolute positioning.
Absolute positioning need a reference point. In order to have a good reference and to get a good control on the elements needing positioning, it’s a good practice to start to put all those elements in a container. The container will be our reference point.
So we start by creating a div, give it a name and make it position:relative. doing so doesn’t change anything visually but this is needed for what comes after.
Now, we pass the image position:absolute. It will then be positioned regarding its most closest positioned parent, that’s why we gave relative to the container.
It’s now easy to position it wherever we want, and it doesn’t affect any other element.