Note that there are some explanatory texts on larger screens.

plurals
  1. POHow do I centre absolutely positioned content of unknown width?
    primarykey
    data
    text
    <p>Before someone asks me why the hell I would want to do this let me come straight out and tell you. That way one of you clever peeps out there can tell me a far better way...</p> <p>I'm making a viewer for paintings which should stretch to fill the page, well 90% of the height of the screen to be precise. I want to fade the paintings in one over the other and want to center each of them in the middle of the screen.</p> <p>To fade the paintings in over each other I need to position them 'absolute' to stop them from stacking. Here's where the trouble comes. Ever since I've set them to absolute, every method I use to center the containing div hasn't worked.</p> <p>Part of the problem is that I'm not setting any width for the paintings as I want them to dynamically size themselves to fill 90% of the user's screen.</p> <p>I've found a hundreds of methods for centering absolute content and believe I might need to shrink wrap the containing div. However I've not had any success as of yet.</p> <p>HTML-</p> <pre><code>&lt;div id="viewer_div"&gt; &lt;img src="" id="first" /&gt; &lt;img id="second" class="hidden"/&gt; &lt;/div&gt; </code></pre> <p>Style Sheet</p> <pre><code>#viewer_div { width:1264px; } img { height:90%; display:block; margin-left: auto; margin-right:auto; } </code></pre> <p>The above gives me the desired effect, but doesn't allow me to position the images absolute. Can anyone suggest a way of centering the images but also allows me to fade one over the other?</p>
    singulars
    1. This table or related slice is empty.
    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.
 

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