Note that there are some explanatory texts on larger screens.

plurals
  1. POIs there a reliable way to position content off to the sides of a div, and have it only appear if the user's resolution allows it?
    primarykey
    data
    text
    <p>I have my markup like this (for argument's sake)</p> <pre><code>&lt;div id="content"&gt;&lt;/div&gt; &lt;div id="layout"&gt;&lt;/div&gt; &lt;div id="layout2"&gt;&lt;/&lt;div&gt; </code></pre> <p>Then I use this CSS</p> <pre><code>#content { width: 800px; height: 600px; margin: 0 auto; } /* place this attached to the top of the page */ #sidebar, #sidebar2 { display: block; width: 139px; height: 100%; position: absolute; top: 0; background: url(../images/layout/pretty.png) repeat-y; } #sidebar { left: 50%; margin-left: -700px; } /* at this point, it appears to the left, and does not trigger scrolling when the window is resized.. it just slides off to the left */ #sidebar2 { right: 50%; margin-right: -700px; } /* now, when you resize, the scrollbar appears as if the content stretches from #sidebar to #sidebar2 */ </code></pre> <p>Is there a reliable way to do this? My only other option is to have a large background image, thats say 1200px wide with my repeating design on the left and right.. but this seems cumbersome if I could get this to work.</p> <p>So my question is, is there a way to position 2 divs which won't affect the browser's interpretation of the width of the page (i.e. as you resize narrower, or smaller resolution, the divs are just hidden out of the viewport?)</p> <p>Thanks!</p> <p><strong>EDIT</strong></p> <p>Thanks for the answers guys, but none are able to give me quite what I want. What's important is these divs that appear outside must be relative to the #content div. They need to appear to the left and right side, and butt up against #content. However, once the browser window is resized to not accommodate them, they should disappear <em>under</em> the viewport. I'd rather not use <code>overflow-x: hidden</code> as I'd like people with small resolutions/windows to be able to scroll left and right to see all the content.</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. 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