1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Vertical alignment in menu list

Discussion in 'CSS' started by Nightmare, May 12, 2006.

  1. #1
    html
    	<div id="menu">
    		<ul>
    			<li><a href="#">menu 1</a></li>
    			<li><a href="#">menu 1</a></li>
    			<li><a href="#">menu 1</a></li>
    		</ul>
    	</div>
    
    Code (markup):
    css
    #menu {
    	background-color:#039ce3;
    	width:100%;
    	padding:0;
    	margin:0;
    	height: 30px;
    }
    
    #menu ul {
    	list-style:none;
    	margin:0;
    	padding:0 0 0 5px;
    }
    
    #menu li {
    	float: left;
    	margin:0;
    	padding:0;
    	width: 120px;
    	border: 1px solid #BEF052;
    }
    
    #menu li a, #menu li a:visited{
    	display: block;
    	float: left;
    	text-align: center;
    	color:#000000;
    	width: 120px;
    	height:28px;
    }
    
    #menu li a:hover {
    	background-color: #13b1fb;
    }
    
    Code (markup):
    result
    [​IMG]

    vertical-align:midle does not work :(

    any idea to resolve this problem?

    Thanks
     
    Nightmare, May 12, 2006 IP
  2. kk5st

    kk5st Prominent Member

    Messages:
    3,497
    Likes Received:
    376
    Best Answers:
    29
    Trophy Points:
    335
    #2
    Set the line-height equal to the container height.

    cheers,

    gary
     
    kk5st, May 12, 2006 IP
  3. Nightmare

    Nightmare Peon

    Messages:
    79
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thanks a lot!!!

    p.s. your links in sign does not work
     
    Nightmare, May 13, 2006 IP
  4. kk5st

    kk5st Prominent Member

    Messages:
    3,497
    Likes Received:
    376
    Best Answers:
    29
    Trophy Points:
    335
    #4
    You're quite welcome. Give the links another try; I have no problem with them.

    cheers,

    gary
     
    kk5st, May 13, 2006 IP
  5. johneva

    johneva Well-Known Member

    Messages:
    1,480
    Likes Received:
    46
    Best Answers:
    1
    Trophy Points:
    170
    #5
    Work good for me too. ;)

    Useful info on there too.
     
    johneva, May 13, 2006 IP
  6. Yoeld

    Yoeld Peon

    Messages:
    152
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    This solution does not work if the menu label is more than one line.

    Any suggestion?
     
    Yoeld, Mar 22, 2009 IP
  7. kk5st

    kk5st Prominent Member

    Messages:
    3,497
    Likes Received:
    376
    Best Answers:
    29
    Trophy Points:
    335
    #7
    It would have been better to start a new topic/thread, with a reference to this thread. Maybe a mod will move it.

    The solution in modern browsers and IE8 is trivial; the solution for IE<8 is non-intuitive, but doable. See centering inline elements vertically.

    cheers,

    gary
     
    kk5st, Mar 22, 2009 IP