html - Vertically center ul in div -


this code looks like.

html

<div id="container">    <ul>       <li>...</li>       <li>...</li>       <li>...</li>    </ul> </div> 

css

#container {   width: 584px;   height: 50px;   position: relative;   overflow: hidden; }  #container ul {   position: absolute;   margin: 0;   padding: 0;   width: 3504px; }  #container ul li {   width: 584px;   float: left;   margin: 0;   padding: 0;   overflow: hidden; } 

as title says, want center ul vertically inside div. cannot change above css rules because. i've been googling solutions , trying find way, seems collide rules have.

any idea how this?

would if instead of #container div used table 1 row , column?

please use search function in future. full answer explained here; code scenario:

.container {   display: table;   height: 100%;   position: absolute;   overflow: hidden;   width: 100%;} .helper {   #position: absolute; /*a variation of "lte ie7" hack*/   #top: 50%;   display: table-cell;   vertical-align: middle;} ul{   #position: relative;   #top: -50%;   margin:0 auto;   width:200px;} 

the 3 elements have nested so:

<div class="container">   <div class="helper">     <ul><!--stuff--></ul>   </div> </div> 

http://jsfiddle.net/ovfiddle/yvaw9/


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -