Results 1 to 6 of 6

Thread: CSS mouse overs

  1. #1
    Join Date
    Dec 2007
    Location
    Mississauga
    Posts
    166
    Thanks
    13
    Thanked 0 Times in 0 Posts

    Default CSS mouse overs

    I have mouse over images for the purpose of using 2 image files on multiple buttons but using html text for the button text.

    I have an issue though where the text is falling to the absolute bottom of the image and I am not able to middle align it or center it. This is my css code...

    Code:
    body {
    	background-image: url(images/bg.jpg);
    	background-repeat: repeat-x;
    }
    #sidebar {
    	vertical-align: none;
    	width: 268px;
    }
    
    #sidebar .lpc{
    	height: 100px;
    	vertical-align: middle;
    }
    
    #sidebar ul {
    	margin: 0;
    	padding: 0;
    	padding-top: 0px;
    }
    
    #sidebar li {
    	list-style: none;
    }
    
    #sidebar li a {
    	display: block;
    	font-size: 14px;
    	color: #556b76;
    	padding: 7px 7px 0px 30px;
    	background-image: url(images/btn.jpg);
    }
    
    #sidebar li a:hover {
    	display: block;
    	background-image: url(images/btno.jpg);
    }
    
    #sidebar li a.selected, a.selected:hover {
    	display: block;
    	color: #820032;
    	background-image: url(images/btn.jpg);
    }
    a:link {
    	text-decoration: none;
    }
    a:visited {
    	text-decoration: none;
    }
    a:hover {
    	text-decoration: none;
    }
    a:active {
    	text-decoration: none;
    }
    a {
    	font-family: Arial, Helvetica, sans-serif;
    	font-size: 12px;
    }
    Can anyone help me here? I can imagine the fix is simple I am just not noticing it.


    -- Nate

  2. #2
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    Put some padding-bottom on the link. Start it at around 10px, then keep increasing it till it reaches the middle, or the part of the link that you want the text at.
    Jeremy | jfein.net

  3. #3
    Join Date
    Mar 2007
    Location
    Currently: New York/Philadelphia
    Posts
    2,735
    Thanks
    3
    Thanked 519 Times in 507 Posts

    Default

    @Nate...

    If Nile's suggestion doesn't work for you, post the HTML that you're trying to use. I'm not sure I understand what you mean here.

  4. #4
    Join Date
    May 2008
    Posts
    7
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default

    You can center text by setting the line-height. So if your buttons are 100px tall, this might work:

    #sidebar li a {
    line-height: 100px;
    display: block;
    font-size: 14px;
    color: #556b76;
    padding: 7px 7px 0px 30px;
    background-image: url(images/btn.jpg);
    }

    Also I'm pretty sure vertical-align tags do absolutely nothing, unless you're working with a table.

    It would help to see your HTML though.
    Hope that helps.
    Last edited by mattpowers; 05-31-2008 at 03:08 PM. Reason: forgot the semi-colon!

  5. #5
    Join Date
    Feb 2008
    Location
    Cebu City Philippines
    Posts
    1,160
    Thanks
    17
    Thanked 277 Times in 275 Posts

    Default

    Quote Originally Posted by mattpowers View Post
    You can center text by setting the line-height. So if your buttons are 100px tall, this might work:

    #sidebar li a {
    line-height: 100px
    display: block;
    font-size: 14px;
    color: #556b76;
    padding: 7px 7px 0px 30px;
    background-image: url(images/btn.jpg);
    }
    ...but throws an error on CSS validation since you're missing ";".
    Learn how to code at 02geek

    The more you learn, the more you'll realize there's much more to learn
    Ray.ph!

  6. #6
    Join Date
    May 2008
    Posts
    7
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default

    You are correct, the post has been edited

    Although I think it's more than a validation error, unless it's the last line in a bracket.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •