Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Either use JavaScript to calculate the width and move it,</p> <p>use a CSS hack to move the element right and left by 50%,</p> <p>or don't absolutely position it.</p> <hr> <p>This answer is incredibly short, but it is to the point. If you require something to be centralised (meaning you would like the browser to determine where the centre point is, and position it there), then you can't use absolute positioning - because that takes away control from the browser.</p> <hr> <blockquote> <p>To fade the paintings in over each other I need to position them 'absolute' to stop them from stacking.</p> </blockquote> <p>This is where your problem lies. You have assumed that you <em>need</em> absolute positioning for the wrong reason.</p> <p>If you are experiencing problems placing elements on top of each other, <strong>wrap the images in an absolutely positioned container which is 100% width and has <code>text-align: center</code></strong></p> <hr> <p>If you do feel that absolute positioning is necessary, the following hack can be used to achieve your desired results:</p> <pre><code>div { position: absolute; /* move the element half way across the screen */ left: 50%; /* allow the width to be calculated dynamically */ width: auto; /* then move the element back again using a transform */ transform: translateX(-50%); } </code></pre> <p>Obviously the above hack has a terrible <a href="https://en.wikipedia.org/wiki/Code_smell" rel="noreferrer">code smell</a>, but it works on some browsers. Be aware: this hack is not necessarily obvious to other developers, or other browsers (especially IE or mobile).</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload