Vertical Alignment on Rollovers Using CSS

Ask a Question related to Macromedia Dynamic HTML, Design and Development.

  1. #1

    Default Vertical Alignment on Rollovers Using CSS

    Greetings --

    I want to use CSS to create a text and image rollover for my navigation. The
    image rolls over just fine but my text insists on a vertical alignment of top
    instead of middle. I have set every parameter I can think of to get the text to
    align itself as I wish but no matter what I try it always aligns to the top.

    I have attached the style sheet text.
    P.S. Horizontal alignment is no problem. It aligns to the center as it should.)

    Thanks.

    Cloudthumper


    <style type="text/css">
    <!--
    body {
    margin-left: 0px;
    margin-top: 0px;
    }
    a:link {
    height: 45px;
    width: 142px;
    display: block;
    font-family: Verdana, Arial, Helvetica, sans-serif;
    font-size: 12px;
    color: #006666;
    text-decoration: none;
    height: 45px;
    width: 142px;
    font-weight: bold;
    background-image: url(images/button-1.jpg);
    vertical-align: middle;
    text-align: center;
    }
    a:hover {
    height: 45px;
    width: 142px;
    display: block;
    font-family: Verdana, Arial, Helvetica, sans-serif;
    font-size: 12px;
    color: #FF0000;
    text-decoration: none;
    height: 45px;
    width: 142px;
    font-weight: bold;
    background-image: url(images/button-2.jpg);
    vertical-align: middle;
    text-align: center;
    }
    -->
    </style>

    cloudthumper Guest

  2. Similar Questions and Discussions

    1. Vertical text-alignment in ComboBox
      Hai there, I'm trying to adjust the text alignment/placement of the text displayed in a combobox, the box height is 18 px but the text inside...
    2. Vertical text alignment in menu spry
      I tried to search this topic with no success. I have created a horizontal spry menu bar. I cannot get the text to align vertically. Everything...
    3. Vertical alignment in table cells
      If I create a table and then merge several cells vertically, I can enter some text and can set the vertical alignment of the new 'spanned' cell to...
    4. Text box vertical alignment... is it possible?
      Well the title said it all... except this: if it is, how?!?
    5. Data Browser vertical alignment problem
      We want to use the features of the data browser in an update to our existing C++ project, but I'm stuck on doing vertical alignment. Alignment...
  3. #2

    Default Re: Vertical Alignment on Rollovers Using CSS

    Well, first of all, there is no need to repeat all of those properties over and
    over, since most of them are the same, most of them can be simply specified
    once, in the <a> element. Use shorthand properties too when you can, to reduce
    code.

    a {
    display: block; font-family: Verdana, Arial, Helvetica, sans-serif;
    font-size: 12px; color: #F00; height: 45px; width: 142px;
    font-weight: bold;vertical-align: middle; text-align: center;
    }

    a:link { background-image: url(images/button-1.jpg); }
    a:visited { background-image: url(images/button-1.jpg); }
    a:hover { background-image: url(images/button-2.jpg); }
    a:active { background-image: url(images/button-2.jpg); }


    mzanime.com Guest

  4. #3

    Default Re: Vertical Alignment on Rollovers Using CSS

    Thanks for your help Michael.

    My problem, however, centers around the text not the image. I want the text
    that I use as the button label to be centered both horizontally and vertically.
    This is text as text not text as a graphic. The text slams itself at the top of
    the table cell not in the middle as I want. I have used every option that I can
    think of to center the text vertically but to no avail. As an example, I have
    posted a representative problem page at:
    [url]http://www.meatballweb.com/css-test/test-css.html[/url]

    I'm beginning to think that it's a flaw in the way css rules are applied by
    both Firefox and IE. Both yield the same results.

    Any assistance would be most welcome.

    Thanks.

    Cloudthumper

    cloudthumper Guest

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139