Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Based off the answers, for anyone who is interested, to scale a CSS background image proportionately with text wrapping, the following should work in most situations.</p> <p>See the <a href="http://jsfiddle.net/dcd018/W8ZTA/" rel="nofollow"><strong>fiddle</strong></a></p> <p>First to ensure the background image isn't rendered larger than mobile resolutions, I added a viewport</p> <pre><code>@media screen and (max-width: 800px){ .viewport { position:absolute; right:0; left:0; top:0; bottom:0; overflow-x:hidden; overflow-y:scroll; } } &lt;html&gt; &lt;body&gt; &lt;div class="viewport"&gt; &lt;!-- background image --&gt; &lt;/div&gt; &lt;/body&gt; &lt;html&gt; </code></pre> <p>Then I used the <code>background-size:cover;</code> property with a height of <code>auto</code> on the background element to allow it to flow with text wrapping on mobile devices. To allow the height of the background element to re-size relative to text wrapping, its parent (in this case, <code>body</code>), must have a height of <code>100%</code>.</p> <pre><code>html,body{ height:100%; } .banner{ background: url('path/to/banner.jpg') center center no-repeat; -webkit-background-size: cover; -moz-background-size: cover; -o-background-size: cover; background-size: cover; } @media screen and (max-width: 800px){ .viewport { position:absolute; right:0; left:0; top:0; bottom:0; overflow-x:hidden; overflow-y:scroll; } .banner{ height:auto; } .banner .banner-container { position:relative; overflow:hidden; } } &lt;html&gt; &lt;body&gt; &lt;div class="viewport"&gt; &lt;div class="banner"&gt; &lt;div class="banner-container"&gt; &lt;h1&gt;Lorem ipsum dolor sit amet, est intellegebat definitionem at&lt;/h1&gt; &lt;h1&gt;Lorem ipsum dolor sit amet, est intellegebat definitionem at&lt;/h1&gt; &lt;h1&gt;Lorem ipsum dolor sit amet, est intellegebat definitionem at&lt;/h1&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/body&gt; &lt;html&gt; </code></pre>
    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.
    1. VO
      singulars
      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