Note that there are some explanatory texts on larger screens.

plurals
  1. POIs it possible to achieve this flexible layout without using JS?
    primarykey
    data
    text
    <p>What I'm trying to achieve without using JS can be seen on <a href="http://jsfiddle.net/k2h5b/4/" rel="nofollow noreferrer">jsfiddle.net/k2h5b/</a>.</p> <p>Basically I would like to display two images, both centered, one in <strong>background</strong> and one in <strong>foreground</strong>:</p> <ul> <li><strong>Background Image</strong>: Should <strong>cover the whole window</strong> without affecting the aspect ratio, which means that the image will always touch two opposite edges of the window, but the image <strong>will be cropped</strong>.</li> <li><strong>Forground Image</strong>: Should be <strong>inside the window</strong> without affecting the aspect ratio, which means the image will be always touch two opposite edges of the window, but the image <strong>will not be cropped</strong>.</li> <li>It doesn't matter if it's a <code>&lt;div&gt;</code> or an <code>&lt;img&gt;</code> tag, as long as they are displaying the images.</li> <li>Asume also that the image sizes are known upfront and can be used in CSS or HTML part.</li> </ul> <p>So my question is: is it possible using only CSS or CSS3? </p> <p>If it's not possible I will accept the answer that will be as close as possible to my goal.</p> <h2>Examples:</h2> <ul> <li><p>When the <strong>background image</strong> is cropped from the top and bottom: <img src="https://i.stack.imgur.com/oJKoh.png" alt="example when background image is cropped from top and the bottom"></p></li> <li><p>When the <strong>background image</strong> when it's cropped from left and right: <img src="https://i.stack.imgur.com/SQr9C.png" alt="example when background image is cropped from left and right"></p></li> </ul>
    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.
 

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