Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Are you looking for <a href="http://jsfiddle.net/LHCbk/">something like this</a>?</p> <p>HTML:</p> <pre><code>&lt;div class="centered"&gt;This is some content in the centered DIV&lt;/div&gt; </code></pre> <p>CSS:</p> <pre><code>.centered { background: #888; margin: 0 auto; width: 50%; } </code></pre> <p>Using <code>margin: 0 auto</code> will center the elements horizontally, meaning that it will have "Equal margin on both sides"</p> <p>You do have to set a width on elements when using the above method, but as shown you can use percentage widths (as I image you may well be for a responsive layout)</p> <p>You cannot however use this technique on floated elements, so you may be looking to add something like this to your CSS:</p> <pre><code>.container { margin: 0 auto; width: 50%; } </code></pre> <p>If I have misunderstood your question please let me know.</p> <p><strong>EDIT:</strong> In response to the comment below I think I have managed to achieve what you're looking for, see this <a href="http://jsfiddle.net/VA4P6/">fiddle</a></p> <p>HTML:</p> <pre><code>&lt;section class="header"&gt; &lt;div href="/" class="logo"&gt;&lt;img src="/images/logo.jpg" /&gt;&lt;/div&gt; &lt;div class="slogan"&gt;&lt;img src="/images/slogan.jpg" /&gt;&lt;/div&gt; &lt;div class="support"&gt;&lt;/div&gt; &lt;/section&gt; </code></pre> <p>CSS:</p> <pre><code>.header { padding: 0 50px 0 300px; position: relative; } .logo, .support { background: red; height: 50px; position: absolute; top: 0; } .support { background: blue; right: 0; width: 50px; } .logo { left: 0; width: 300px; } .slogan { background: black; height: 50px; margin: 0 auto; width: 50px; } </code></pre> <p>The positioning/padding aspect of things isn't particularly pretty (if the width of .support or .logo change, you have to change that in the css) however I <em>think</em> this is the only safe way of doing it with pure HTML/CSS in a cross browser way (I'd be interested to see anyone elses take on it though), the important this is that it works and is completely valid.</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.
 

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