css float - Create columns in CSS menu -


i'm attempting build phone directory css dropdown menu. i'm aiming render typical phone book would, names aligned left , phone extensions/numbers aligned right, so:

james t. kirk                    x1701 mr. spock               (123) 555-8795 

the html pretty straightforward:

<ul id="phone">  <li>     phone category 1     <ul>         <li>             <span class="phone-description">phone description 1</span>             <span class="phone-number">x55555</span>         </li>         <li>             <span class="phone-description">longer phone description 2</span>             <span class="phone-number">(800) 555-1234 x1701</span>         </li>     </ul> </li>  ...  </ul> 

the basic formatting simple well:

body {background: #999;} ul {list-style: none; margin: 0; padding: 0;} li {margin: 0; padding: 0.4em 2em 0.4em 1em; white-space: nowrap;}  #phone {position: fixed; top: 0; left: 0;} #phone li {background: #fff; position: relative;} #phone li:hover {background: #ccc;} #phone ul {display: none; position: absolute; top: 0; left: 100%;} #phone li:hover ul {display: block;}  .phone-number {margin-left: 2em;} 

making columns, however, has proven extremely difficult. i've attempted using text-align, floats, absolute positioning, , css brilliance explained @ "fluid width equally spaced divs."

i've put above code @ http://jsfiddle.net/hq4zn/2/, along each of attempted solutions commented out. can provide appreciated!

just use css display:table

<!doctype html> <html> <head> <meta charset="utf-8"> <title>untitled document</title> <style> .category{display:table} .category li {display:table-row} .category span {display:table-cell}  </style> </head>  <body> <ul id="phone">  <li>     phone category 1     <ul class="category">         <li>             <span class="phone-description">phone description 1</span>             <span class="phone-number">x55555</span>         </li>         <li>             <span class="phone-description">longer phone description 2</span>             <span class="phone-number">(800) 555-1234 x1701</span>         </li>     </ul> </li>  </ul> </body> </html> 

Comments

Popular posts from this blog

curl - PHP fsockopen help required -

HTTP/1.0 407 Proxy Authentication Required PHP -

c# - Resource not found error -