Results 1 to 5 of 5

Thread: 2 line horizontal navigation?

  1. #1
    Join Date
    Jan 2007
    Location
    Indiana
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default 2 line horizontal navigation?

    I'm working on creating a simple horizontal navigation bar (bg and fg change on hover) with an added twist. I'd like the menu to allow two lines of text for each element in the bar. I've tried limiting the width of the elements in an attempt to cause the text to wrap, but that didn't seem to do much. Any thoughts?

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    If the elements are block level - like a div or a p, or if they have their display property set to block, making them block level for layout purposes, then giving them adequate height or even just allowing them to expand vertically by not giving them any height property and not containing them within an element with a restrictive height set, then they will wrap if their width is too narrow for the text.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #3
    Join Date
    Jan 2007
    Location
    Indiana
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    So, the issue isn't getting an item to wrap as much as it is getting block elements to wrap while being displayed inline.

    If I remove the display:inline; element from the CSS definition for the div tag, the div elements wrap as expected. However, when the display:inline element is present in the div tag definition, the div elements in the navigation menu no longer wrap.

    So it seems that the display:inline element and the display:block element are mutually exclusive, and I'm looking for a way to somehow combine the two.

    I've also tried placing a block style element within an inline element with no different results.

    any insight?

  4. #4
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    A block level element may be made to appear as if it is inline if floated:

    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd">
    <html>
    <head>
    <title></title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <style type="text/css">
    .floater {
    width:8em;
    height:2.5em;
    float:left;
    margin-right:1.5em;
    border:1px solid #cccccc;
    }
    </style>
    </head>
    <body>
    <div><div class="floater">some content that can wrap once</div>
    <div class="floater">some content that can wrap once</div>
    <div class="floater">some content that can wrap once</div>
    <div class="floater">some content that can wrap once</div>
    <div class="floater">some content that can wrap once</div>
    <div style="clear:left;"></div></div>
    </body>
    </html>
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  5. #5
    Join Date
    Jan 2007
    Location
    Indiana
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Thumbs up

    AHA! Floating the elements worked. Thanks!

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
  •