Note that there are some explanatory texts on larger screens.

plurals
  1. POCSS center display inline block?
    primarykey
    data
    text
    <p>I have a working code here: <a href="http://jsfiddle.net/WVm5d/" rel="noreferrer">http://jsfiddle.net/WVm5d/</a> (you might need to make the result window bigger to see the align center effect)</p> <p><strong>Question</strong></p> <p>The code works fine but I don't like to have <code>display: table;</code>. It's the only way I could make the wrap-class align center. I think it would be better if there was a way to use <code>display: block;</code> or <code>display: inline-block;</code>. Is it possible to solve the align center another way?</p> <p>Adding a fixed with to the container is not an option for me.</p> <p><strong>I will also paste my code here if the JS Fiddle link gets broken in the future:</strong></p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-css lang-css prettyprint-override"><code>body { background: #bbb; } .wrap { background: #aaa; margin: 0 auto; display: table; overflow: hidden; } .sidebar { width: 200px; float: left; background: #eee; } .container { margin: 0 auto; background: #ddd; display: block; float: left; padding: 5px; } .box { background: #eee; border: 1px solid #ccc; padding: 10px; margin: 5px; float: left; } .box:nth-child(3n+1) { clear: left; }</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div class="wrap"&gt; &lt;div class="sidebar"&gt; Sidebar &lt;/div&gt; &lt;div class="container"&gt; &lt;div class="box"&gt; Height1 &lt;/div&gt; &lt;div class="box"&gt; Height2&lt;br /&gt; Height2 &lt;/div&gt; &lt;div class="box"&gt; Height3&lt;br /&gt; Height3&lt;br /&gt; Height3 &lt;/div&gt; &lt;div class="box"&gt; Height1 &lt;/div&gt; &lt;div class="box"&gt; Height2&lt;br /&gt; Height2 &lt;/div&gt; &lt;div class="box"&gt; Height3&lt;br /&gt; Height3&lt;br /&gt; Height3 &lt;/div&gt; &lt;/div&gt; &lt;div class="sidebar"&gt; Sidebar &lt;/div&gt; &lt;/div&gt;</code></pre> </div> </div> </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