css buttons - formatting text breaks alignment ?

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

  1. #1

    Default Re: css buttons - formatting text breaks alignment ?

    Okay, the first thing I see is that you haven't declared a DOCTYPE in your
    web page. This causes modern browsers to revert to "quirks mode," meaning
    that the browser renders the page the way older, non-standards-compliant
    browsers would have. If you add a DOCTYPE to the top of the page (as you
    should), your blue and pink areas disappear altogether, and everything else
    gets resized and shoved about. That's the browser rendering the CSS in a
    more modern way.

    So, I would recommend a different approach:
    1. Create the entire button image (with no text) as a GIF, rather than
    trying to piece it together from various bits.
    2. Markup your menu as an unordered list.
    3. Write your CSS to use the button as the background for each <li> element,
    with the text styled to your liking.

    I think you'll end up with cleaner page markup and fewer CSS classes. Here's
    a quick start on what I'm talking about:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    <html>
    <head>
    <title>Untitled Document</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <link href="button.css" rel="stylesheet" type="text/css">
    </head>
    <body>

    <div id="menu">
    <ul>
    <li><a href="#">button 1</a></li>
    <li><a href="#">button 2</a></li>
    <li><a href="#">button 3</a></li>
    </ul>
    </div>

    </body>
    </html>

    Then the CSS:
    #menu li a {
    width: 120px;
    text-align: center;
    list-style: none;
    font-size: 12px;
    font-style: bold;
    line-height: 24px;
    font-family: Verdana, Arial, Helvetica, sans-serif;
    background-image: url("button.GIF");
    background-repeat : no-repeat;
    }

    That said, I hope I've pointed you in the direction you want to go. I've
    made some assumptions about what you're trying to accomplish that may or may
    not be correct. Also, this is just a start; there's more styling that's
    necessary to make it work across browsers. I highly recommend Designing with
    Web Standard by Jeffrey Zeldman and Eric Meyer on CSS for more detailed CSS
    instruction.

    Doug B.


    Douglas Burton Guest

  2. Similar Questions and Discussions

    1. addWatermarkFromText- Text Alignment
      I got the VB.Net sample code from the SDK zip and I'm programming against Acrobat 8. I had no problems modifying the code for my own use except for...
    2. text alignment buttons not active
      I am trying to use contribute align left, center and right buttons to format text and images but am unable to. They are greyed out. What could be...
    3. UIScrollBar Breaks CSS Formatting
      :confused; Hi people. I'm trying to load some CSS-formatted HTML text into a text field in Flash MX 2004. I've managed to assign the external...
    4. Alignment Buttons not functioning
      The alignment buttons at the top of Contribute 3 are not functioning for my client. Is there a way that I can get them working again for him?
    5. Flash & Text alignment
      I'd like to have a webpage with a Flash movie at the top and plain text (not part of the flash movie) just to the right of it. I can NOT use any...
  3. #2

    Default Re: css buttons - formatting text breaks alignment ?

    Hey Douglas

    Thanks for the info mate, that was really helpful. I have designed websites
    for a while now, but always in HTML, and this is my first attempt at trying
    to make a site totally marked up with CSS, and so my first faltering steps
    are quite untidy and probably convoluted judging by your neat css code.

    However the reason I am usijng various bits to construct the buttons is that
    the button text will be dynamic depending on which category the user is
    coming from. I did end up working out a way of doing it, but im not sure how
    the DOCTYPE declaration will affect it yet ... I see how its torn my
    button.asp file apart, but if thats the proper way to do it, thats the way I
    will do it from now on.

    Again doug, thanks for the time - i have been toying with the idea of buying
    Jeffrey Zeldman and Eric Meyer's books from amazon ... maybe its time I did.

    cheers!

    <dG />

    "Douglas Burton" <doug@dougandsarah.net> wrote in message
    news:bi1ipe$2ve$1@forums.macromedia.com...
    > Okay, the first thing I see is that you haven't declared a DOCTYPE in your
    > web page. This causes modern browsers to revert to "quirks mode," meaning
    > that the browser renders the page the way older, non-standards-compliant
    > browsers would have. If you add a DOCTYPE to the top of the page (as you
    > should), your blue and pink areas disappear altogether, and everything
    else
    > gets resized and shoved about. That's the browser rendering the CSS in a
    > more modern way.
    >
    > So, I would recommend a different approach:
    > 1. Create the entire button image (with no text) as a GIF, rather than
    > trying to piece it together from various bits.
    > 2. Markup your menu as an unordered list.
    > 3. Write your CSS to use the button as the background for each <li>
    element,
    > with the text styled to your liking.
    >
    > I think you'll end up with cleaner page markup and fewer CSS classes.
    Here's
    > a quick start on what I'm talking about:
    > <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    > "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    > <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    > <html>
    > <head>
    > <title>Untitled Document</title>
    > <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    > <link href="button.css" rel="stylesheet" type="text/css">
    > </head>
    > <body>
    >
    > <div id="menu">
    > <ul>
    > <li><a href="#">button 1</a></li>
    > <li><a href="#">button 2</a></li>
    > <li><a href="#">button 3</a></li>
    > </ul>
    > </div>
    >
    > </body>
    > </html>
    >
    > Then the CSS:
    > #menu li a {
    > width: 120px;
    > text-align: center;
    > list-style: none;
    > font-size: 12px;
    > font-style: bold;
    > line-height: 24px;
    > font-family: Verdana, Arial, Helvetica, sans-serif;
    > background-image: url("button.GIF");
    > background-repeat : no-repeat;
    > }
    >
    > That said, I hope I've pointed you in the direction you want to go. I've
    > made some assumptions about what you're trying to accomplish that may or
    may
    > not be correct. Also, this is just a start; there's more styling that's
    > necessary to make it work across browsers. I highly recommend Designing
    with
    > Web Standard by Jeffrey Zeldman and Eric Meyer on CSS for more detailed
    CSS
    > instruction.
    >
    > Doug B.
    >
    >

    dark Guest

  4. #3

    Default Re: css buttons - formatting text breaks alignment ?

    Happy to help!

    Glad you worked it out. The <ul> markup is just one way to to do it, and it
    would still allow you to make your button text dynamic. Are you pulling the
    menu items from a database?

    Cheers,

    Doug


    Douglas Burton Guest

  5. #4

    Default Re: css buttons - formatting text breaks alignment ?

    I see, yes. You have set up a tricky situation for yourself. I've been
    looking for an existing example of the sort of thing you're doing, but I
    haven't found anything yet. I'll keep you in mind if I come across
    something. Meanwhile, you've got something that works for you, so carry on!

    Doug


    "dark" <darkgr33n@btclick.com> wrote in message
    news:bi2lsq$p2u$1@forums.macromedia.com...
    > hey doug
    >
    > yeah, menu items will come from database eventually, which is why i need
    the
    > width of the button itself to be dynamic ... could be 10 characters long,
    > could be 40 characters long ... and why i had been chopping up the
    buttons,
    > to put a curved 'cap' on each end. much more difficult than i thought,
    > especially when declaring the DOCTYPE!
    >
    > I have ended up with a slightly convoluted method but it appears to work
    >
    > code...
    >
    > <div class="menuButtonBox">
    > <div class="centre">
    > <div class="line">
    > <div class="l"> </div>
    > <a href="javascript:viewPage();"><p>INFO / VIEW</p></a>
    > <div class="r"> </div>
    > </div>
    > </div>
    > </div>
    >
    > css...
    >
    > .menuButtonBox {
    > width: 130px;
    > height: 22px;
    > text-align: center;
    > }
    >
    > .centre {
    > margin-top: 5px;
    > text-align: center;
    > }
    >
    > .line {
    > display: inline;
    > position: relative;
    > background: #000;
    > text-align: center;
    > line-height: 20px;
    > height: 20px;
    > margin: 10px auto 0 auto;
    > padding: 0;
    > }
    >
    > .line p {
    > display: inline;
    > font-family: Verdana,Arial,Helvetica,sans-serif;
    > font-weight: bold;
    > font-size: 10px;
    > margin: 0;
    > padding: 0 10px 0 10px;
    > line-height: 19px; /* Hack for Mozilla */
    > height: 20px;
    > }
    >
    > .line a {
    > color: #cccccc;
    > text-decoration: none;
    > cursor: hand;
    > }
    >
    > .line a:hover {
    > color: #fff;
    > }
    >
    > .line .l, .line .r {
    > width: 2px;
    > height: 20px;
    > position: absolute;
    > top: 0;
    > }
    >
    > .line .l { background-image: url(images/buttonLend.gif); }
    > .line .r { background-image: url(images/buttonRend.gif); }
    >
    > hmmm, seems quite long for a few buttons but does seem to work, except in
    > netscape ... but then nutscrape has always been a different kettle o fish,
    > and current stats say around 1.4% of viewers still use it so im going for
    IE
    > while learning
    >
    > layout as a whole in css is quite difficult, but maybe thats because im
    > thinking in tables still, but im getting there, and leaving the stuff
    thats
    > hard to layout in css in tables until css dom gets better
    >
    > cheers
    >
    > <dG />
    >
    >
    > "Douglas Burton" <doug@dougandsarah.net> wrote in message
    > news:bi2jfh$kkn$1@forums.macromedia.com...
    > > Happy to help!
    > >
    > > Glad you worked it out. The <ul> markup is just one way to to do it, and
    > it
    > > would still allow you to make your button text dynamic. Are you pulling
    > the
    > > menu items from a database?
    > >
    > > Cheers,
    > >
    > > Doug
    > >
    > >
    >
    >

    Douglas Burton 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