How to align text in a floated DIV

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • donpro

    How to align text in a floated DIV

    Hi,

    I have the following code snippet:

    <div id="header_menu items">
    <a href="home" title="Home page">Home</a|
    <a href="aboutus" title="About Us">About Us</a|
    <a href="contactus " title="Contact Us">Contact Us</a|
    <a href="home" title="Login">L ogin</a>
    </div>


    and accompanying CSS code:

    #header_menuite ms {
    float: left;
    padding-top: 5px;
    padding-right: 10px;
    color: white;
    font-weight: bold;
    text-align: right;
    }

    My problem is that the links are not aligning to the right of the DIV
    (tested in Firefox and IE 7). However, if I comment out the:

    float: left;

    Then it aligns to the right of the DIV. Is this normal behavior and
    if so, is there a work-around?

    Thanks,
    Don
  • dorayme

    #2
    Re: How to align text in a floated DIV

    In article
    <f96714b5-4f4a-4434-ac09-82f7fbfbffd9@34 g2000hsh.google groups.com>,
    donpro <donpro-2003@rogers.com wrote:
    Hi,
    >
    I have the following code snippet:
    >
    <div id="header_menu items">
    <a href="home" title="Home page">Home</a|
    <a href="aboutus" title="About Us">About Us</a|
    <a href="contactus " title="Contact Us">Contact Us</a|
    <a href="home" title="Login">L ogin</a>
    </div>
    >
    >
    and accompanying CSS code:
    >
    #header_menuite ms {
    float: left;
    padding-top: 5px;
    padding-right: 10px;
    color: white;
    font-weight: bold;
    text-align: right;
    }
    >
    My problem is that the links are not aligning to the right of the DIV
    (tested in Firefox and IE 7).
    Yes it is aligning to the right but you cannot see it because a float
    shrinks the width to fit the content. To see it, add a generous width
    and a *black* border to the div.


    However, if I comment out the:
    >
    float: left;
    >
    Then it aligns to the right of the DIV. Is this normal behavior and
    if so, is there a work-around?
    You have not quite described what you want worked around. You want the
    menu to be on the left of the page generally but right within something
    else. See above and supply a url for further information

    --
    dorayme

    Comment

    Working...