Note that there are some explanatory texts on larger screens.

plurals
  1. POVertically Centering CSS Heading with Floated Controls
    primarykey
    data
    text
    <p>I keep running into cases where I want to have to inline-block elements on opposite ends of the same "line" but I also want them to vertically align.</p> <p>An example of what I am talking about is here: <a href="http://jsfiddle.net/96DJv/4/" rel="nofollow">http://jsfiddle.net/96DJv/4/</a> (look at the buttons, I want them to align with the heading)</p> <p>The markup:</p> <pre><code>&lt;div class="people"&gt; &lt;div class="head"&gt; &lt;div class="controls"&gt; &lt;button&gt;Delete&lt;/button&gt; &lt;select&gt; &lt;option&gt;Some Option&lt;/option&gt; &lt;/select&gt; &lt;!-- additional inline-block elements --&gt; &lt;/div&gt; &lt;h1 class="title"&gt;Title&lt;/h1&gt; &lt;/div&gt; &lt;table class="list"&gt; &lt;tr&gt; &lt;th&gt;Name&lt;/th&gt;&lt;th&gt;Age&lt;/th&gt;&lt;th&gt;Score&lt;/th&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;John&lt;/td&gt;&lt;td&gt;14&lt;/td&gt;&lt;td&gt;200&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;Jack&lt;/td&gt;&lt;td&gt;23&lt;/td&gt;&lt;td&gt;2100&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;/div&gt; </code></pre> <p>The style:</p> <pre><code>.people { width: 400px; } .list { width: 100%; } .list th { text-align: left; } .title { overflow:hidden; } .controls { float: right; } .head { background-color: #F1F1F1; } </code></pre> <p>From what I hear floating an element removes your ability to change the vertical align of that element. So are the only options I am left with using position: absolute or tables? Is there another way to accomplish this goal?</p> <p>I've been searching for hours and still haven't found a solution that works.</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.
    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