Note that there are some explanatory texts on larger screens.

plurals
  1. POVertically centering elements
    primarykey
    data
    text
    <p>I need to vertically align with CSS multiple elements inside my header.</p> <p>At the moment, I am using this structure:</p> <pre><code>-Header -Content div (This only set my width to 940 with paddings of 10px each side) -Element 1 (Height: Known, 50px) -Element 2 (Height: Unknown, bigger fonts) -Element 3 (Height: Unknown, smaller fonts) </code></pre> <p>So I need to vertically align to the middle (50% of my header - size of the element) all of my elements and I need to make it cross-browser compatible...</p> <p>I've found some suggestion by searching such as using a floater div, however I had a hard time trying to align all of my elements since they are not all of the same size...</p> <p><strong>EDIT</strong> As requested, here is my HTML and CSS:</p> <p><em><strong>HTML:</em></strong></p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;link rel="stylesheet" type="text/css" href="../CSS/mediadevis.css" /&gt; &lt;/head&gt; &lt;body&gt; &lt;header&gt; &lt;div class="content"&gt; &lt;div id="logo"&gt;&lt;/div&gt; &lt;nav&gt; &lt;ul&gt; &lt;li&gt;Accueil&lt;/li&gt; &lt;li&gt;Nos services&lt;/li&gt; &lt;li&gt;Notre compagnie&lt;/li&gt; &lt;li&gt;Nous joindre&lt;/li&gt; &lt;/ul&gt; &lt;/nav&gt; &lt;div id="lang"&gt;English&lt;/div&gt; &lt;/div&gt; &lt;/header&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p><em><strong>CSS:</em></strong></p> <pre><code>body { margin: 0; background-color: #336699; } header{ background-image:url('../IMG/bg_top.png'); height: 90px; } nav &gt; ul{ float: left; list-style-type:none; margin:0; margin-left: 10px; padding:0; color: #ffffff; } nav &gt; ul &gt; li{ display: inline; font-family: Arial, Helvetica, sans-serif; font-size: 20px; padding: 10px; } .content{ margin: auto; width: 940px; padding-right: 10px; padding-left: 10px; } #lang{ float: left; } #logo{ background-image:url('../IMG/logo.png'); height: 50px; width: 180px; float: left; } </code></pre>
    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.
 

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