2 lists: 1 left aligned and 1 right aligned on same line

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

    2 lists: 1 left aligned and 1 right aligned on same line

    Hi All,

    Why doesn't this work in Firefox but is perfect in IE6?

    In IE6, the text is on the same line but in Firefox, the left aligned text
    is on the line above the right aligned text.

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <title>Untitl ed Document</title>
    <style type="text/css">
    <!--
    body {
    font-family: Geneva, Arial, Helvetica, sans-serif;
    font-size: 77%;
    margin: 0;
    padding: 0;
    }
    a, a:visited {
    color: #00f;
    text-decoration: none;
    }
    a:hover {
    color: #f60;
    text-decoration: underline;
    }
    #basicnav {
    padding: 4px 0;
    margin: 0;
    width: 100%;
    background-color: #999;
    border-top: 1px solid #ccc;
    border-bottom: 1px solid #000;
    }
    #basicnav a, #basicnav a:visited {
    color: #fff;
    text-decoration: none;
    font-weight: bold;
    }
    #basicnav a:hover {
    color: #000;
    text-decoration: underline;
    font-weight: bold;
    }
    #topleftnavlist li {
    display: inline;
    list-style-type: none;
    float: left;
    padding-left: 20px;
    }
    #toprightnavlis t li {
    display: inline;
    list-style-type: none;
    float: right;
    padding-right: 20px;
    }
    -->
    </style>
    </head>

    <body>

    <div id="basicnav">

    <ul id="topleftnavl ist">
    <li><a href="#">Home</a></li>
    </ul>

    <ul id="toprightnav list">
    <li><a href="#">Site map</a></li>
    <li><a href="#">Sell our products</a></li>
    <li><a href="#">Contac t us</a></li>
    </ul>

    </div>

    </body>
    </html>

    Thanks,

    JB


  • Darin McGrew

    #2
    Re: 2 lists: 1 left aligned and 1 right aligned on same line

    JB <me@here.com> wrote:[color=blue]
    > Why doesn't this work in Firefox but is perfect in IE6?[/color]

    You specified "display: inline" for the LI elements, but not for the UL
    elements that contain them. That might have something to do with it.
    [color=blue]
    > body {
    > font-family: Geneva, Arial, Helvetica, sans-serif;
    > font-size: 77%;[/color]

    Please don't inflict microfonts on your readers. Normal body text should
    use a font size of 100%. Only legalese and similar fine-print should use
    smaller fonts.
    --
    Darin McGrew, mcgrew@stanford alumni.org, http://www.rahul.net/mcgrew/
    Web Design Group, darin@htmlhelp. com, http://www.HTMLHelp.com/

    "If you find yourself in a hole, stop digging." - Will Rogers

    Comment

    • JB

      #3
      Re: 2 lists: 1 left aligned and 1 right aligned on same line

      > You specified "display: inline" for the LI elements, but not for the UL[color=blue]
      > elements that contain them. That might have something to do with it.[/color]

      I added:

      #basicnav ul{
      display: inline:
      }

      but it didn't line them up :(
      [color=blue][color=green]
      >> body {
      >> font-family: Geneva, Arial, Helvetica, sans-serif;
      >> font-size: 77%;[/color]
      >
      > Please don't inflict microfonts on your readers. Normal body text should
      > use a font size of 100%. Only legalese and similar fine-print should use
      > smaller fonts.[/color]

      I took this font-sizing from an article on alistapart.

      Thanks for your feedback.

      Jeff


      Comment

      • Stan Brown

        #4
        Re: 2 lists: 1 left aligned and 1 right aligned on same line

        Thu, 23 Feb 2006 23:32:00 -0000 from JB <me@here.com> :[color=blue]
        > <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
        > "http://www.w3.org/TR/html4/loose.dtd">[/color]

        Please don't post HTML or CSS; give us the URL so that we can try it
        using our browsers.

        --
        Stan Brown, Oak Road Systems, Tompkins County, New York, USA

        HTML 4.01 spec: http://www.w3.org/TR/html401/
        validator: http://validator.w3.org/
        CSS 2.1 spec: http://www.w3.org/TR/CSS21/
        validator: http://jigsaw.w3.org/css-validator/
        Why We Won't Help You:

        Comment

        • Jim Moe

          #5
          Re: 2 lists: 1 left aligned and 1 right aligned on same line

          JB wrote:[color=blue]
          >
          > Why doesn't this work in Firefox but is perfect in IE6?
          >[/color]
          <ul> is the block element you want to float, not the <li>s.
          You need only set the right nav <ul> float:right.

          --
          jmm (hyphen) list (at) sohnen-moe (dot) com
          (Remove .AXSPAMGN for email)

          Comment

          • JB

            #6
            Re: 2 lists: 1 left aligned and 1 right aligned on same line

            > Please don't post HTML or CSS; give us the URL so that we can try it[color=blue]
            > using our browsers.
            >
            > --
            > Stan Brown, Oak Road Systems, Tompkins County, New York, USA[/color]


            Hi Stan,

            URL is: http://www.borovere.plus.com/css/new.htm

            I tried removing the float:left but that messed it up in IE6.

            I could have achieved what I want using a <table> in seconds but I must
            stick with using CSS! Help!

            Jeff


            Comment

            • JB

              #7
              Re: 2 lists: 1 left aligned and 1 right aligned on same line

              Ok, I've got it working perfectly in IE6 but the background is not covering
              the DIV area in Firefox - any ideas why?



              The links are white so are invisible unless the DIV background colour is
              displayed behind them. Do I need to specify a height for the #basicnav DIV?

              Thanks,

              Jeff


              Comment

              • JB

                #8
                Re: 2 lists: 1 left aligned and 1 right aligned on same line


                "JB" <me@here.com> wrote in message
                news:43ff390e$0 $82667$ed2619ec @ptn-nntp-reader03.plus.n et...[color=blue]
                > Ok, I've got it working perfectly in IE6 but the background is not
                > covering the DIV area in Firefox - any ideas why?
                >
                > http://www.borovere.plus.com/css/new.htm
                >
                > The links are white so are invisible unless the DIV background colour is
                > displayed behind them. Do I need to specify a height for the #basicnav
                > DIV?
                >
                > Thanks,
                >
                > Jeff
                >[/color]

                :-(

                I just tried shrinking the browser size and it all messes up and wraps to
                multiple lines as the window gets smaller.

                Long live Tables. CSS is a nightmare.


                Comment

                • IEDesigner

                  #9
                  Re: 2 lists: 1 left aligned and 1 right aligned on same line

                  "JB" <me@here.com> wrote in message
                  news:43ff3d6e$0 $82645$ed2619ec @ptn-nntp-reader03.plus.n et...[color=blue]
                  >
                  > "JB" <me@here.com> wrote in message
                  > news:43ff390e$0 $82667$ed2619ec @ptn-nntp-reader03.plus.n et...[color=green]
                  > > Ok, I've got it working perfectly in IE6 but the background is not
                  > > covering the DIV area in Firefox - any ideas why?
                  > >
                  > > http://www.borovere.plus.com/css/new.htm
                  > >
                  > > The links are white so are invisible unless the DIV background colour is
                  > > displayed behind them. Do I need to specify a height for the #basicnav
                  > > DIV?
                  > >
                  > > Thanks,
                  > >
                  > > Jeff
                  > >[/color]
                  >
                  > :-(
                  >
                  > I just tried shrinking the browser size and it all messes up and wraps to
                  > multiple lines as the window gets smaller.
                  >
                  > Long live Tables. CSS is a nightmare.[/color]

                  What you have described is considered an asset of fluid design. You could
                  specify a fixed width in pixels. Ducking back into my hole now.
                  IEDesigner


                  Comment

                  • JB

                    #10
                    Re: 2 lists: 1 left aligned and 1 right aligned on same line

                    >> I just tried shrinking the browser size and it all messes up and wraps to[color=blue][color=green]
                    >> multiple lines as the window gets smaller.
                    >>
                    >> Long live Tables. CSS is a nightmare.[/color]
                    >
                    > What you have described is considered an asset of fluid design. You could
                    > specify a fixed width in pixels. Ducking back into my hole now.
                    > IEDesigner
                    >
                    >[/color]

                    Hee Hee. I was almost crucified here recently for using fixed width!

                    Jeff


                    Comment

                    • Spartanicus

                      #11
                      Re: 2 lists: 1 left aligned and 1 right aligned on same line

                      Please list important information not just in the message header, but
                      repeat it in the message body.

                      "JB" <me@here.com> wrote:

                      Subject: 2 lists: 1 left aligned and 1 right aligned on same line

                      About: http://www.borovere.plus.com/css/new.htm

                      Why are you using 2 lists?

                      Your minimised test case doesn't allow us to see the context and thus
                      what you are actually trying to do.

                      Judging by the little information that is there one list seems more
                      appropriate.

                      If you want something resembling this navbar:


                      It can be done by setting <li> to inline, specifying text-align:right on
                      the <ul>, specify position:relati ve on the <ul> to make it the
                      containing element, absolutely positioning the one link you want left
                      aligned, and then giving the <ul> a left padding in em's to the size of
                      the positioned link text.

                      --
                      Spartanicus

                      Comment

                      • Jim Moe

                        #12
                        Re: 2 lists: 1 left aligned and 1 right aligned on same line

                        JB wrote:[color=blue]
                        >
                        > I just tried shrinking the browser size and it all messes up and wraps to
                        > multiple lines as the window gets smaller.
                        >
                        > Long live Tables. CSS is a nightmare.
                        >[/color]
                        Only if you expect CSS to provide exactly the same styling as tables. I
                        doubt you were instantly proficient with table-based layout.
                        The floating and positioning aspects of CSS take a while to understand
                        and apply properly.

                        --
                        jmm (hyphen) list (at) sohnen-moe (dot) com
                        (Remove .AXSPAMGN for email)

                        Comment

                        • Johannes Koch

                          #13
                          Re: 2 lists: 1 left aligned and 1 right aligned on same line

                          JB wrote:[color=blue]
                          > Long live Tables. CSS is a nightmare.[/color]

                          It's not about Tables vs. CSS, it's about various rendering mechanisms.
                          There's a way do present something in a way HTML tables are usually
                          rendered, which is part of CSS for 7 3/4 years now
                          (<http://www.w3.org/TR/REC-CSS2/tables.html>). Unfortunately, Win IE ...
                          --
                          Johannes Koch
                          Spem in alium nunquam habui praeter in te, Deus Israel.
                          (Thomas Tallis, 40-part motet)

                          Comment

                          • Spartanicus

                            #14
                            Re: 2 lists: 1 left aligned and 1 right aligned on same line

                            Johannes Koch <koch@w3develop ment.de> wrote:
                            [color=blue][color=green]
                            >> Long live Tables. CSS is a nightmare.[/color]
                            >
                            >It's not about Tables vs. CSS, it's about various rendering mechanisms.
                            >There's a way do present something in a way HTML tables are usually
                            >rendered, which is part of CSS for 7 3/4 years now
                            >(<http://www.w3.org/TR/REC-CSS2/tables.html>). Unfortunately, Win IE ...[/color]

                            A CSS table layout has all the drawbacks that HTML tables suffer from
                            except for the semantics issue, on top of that CSS tables lack features
                            that HTML tables do have.

                            CSS 2.x doesn't offer any proper layout tools, all CSS 2.x methods have
                            huge flaws when used for layouts.

                            --
                            Spartanicus

                            Comment

                            • JB

                              #15
                              Re: 2 lists: 1 left aligned and 1 right aligned on same line


                              "Spartanicu s" <invalid@invali d.invalid> wrote in message
                              news:fcguv112jn mmmo69jts9v440v pd7n1eg1h@news. spartanicus.utv internet.ie...[color=blue]
                              > Please list important information not just in the message header, but
                              > repeat it in the message body.
                              >
                              > "JB" <me@here.com> wrote:
                              >
                              > Subject: 2 lists: 1 left aligned and 1 right aligned on same line
                              >
                              > About: http://www.borovere.plus.com/css/new.htm
                              >
                              > Why are you using 2 lists?
                              >
                              > Your minimised test case doesn't allow us to see the context and thus
                              > what you are actually trying to do.
                              >
                              > Judging by the little information that is there one list seems more
                              > appropriate.
                              >
                              > If you want something resembling this navbar:
                              > http://www.pan-europe.utvinternet.ie/links.htm
                              >
                              > It can be done by setting <li> to inline, specifying text-align:right on
                              > the <ul>, specify position:relati ve on the <ul> to make it the
                              > containing element, absolutely positioning the one link you want left
                              > aligned, and then giving the <ul> a left padding in em's to the size of
                              > the positioned link text.
                              >
                              > --
                              > Spartanicus[/color]

                              Hi Spartanicus,

                              Great advice thanks. It now looks great in Firefox but is messed up in IE6.
                              The "home" link which I want to be on the left of the screen is now
                              appearing 3 ems (padding-left) from the leftmost part of the <ul>. When I
                              set the width of the <ul> to 100%, it looks perfect in IE6 but in Firefox, I
                              get a horizontal scroll.

                              So close! http://www.borovere.plus.com/css/new.htm

                              Thanks,

                              Jeff


                              Comment

                              Working...