Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: Aligning Left/Center/Right on Same Line?

  1. #1
    Join Date
    Apr 2006
    Posts
    27
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Aligning Left/Center/Right on Same Line?

    Is it possible to have text aligned to the left, center, and right all on the same line without any line breaks? I have used the <div style="float:left"> or <div style="float:right"> to align text on the left side and the right side with out any line breaks, but how can i get text to be in the middle of those two without line breaking?

    ~Thanks

  2. #2
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Yes, but you need three different block-level elements:
    Code:
    <p style="float: left; width: 32&#37;; text-align: left;">Left text</p>
    <p style="float: left; width: 32%; text-align: center;">Centre text</p>
    <p style="float: left; width: 32%; text-align: right;">Right text</p>
    Note that I left 4% free for margins, borders and the like. That may differ for you depending on the rest of your stylesheet.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  3. #3
    Join Date
    Apr 2006
    Posts
    27
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    After the left text the line breaks but the center and right text are one the same line how can i have it so that all the text is on the same line and no breaks?

  4. #4
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Hence my comment:
    Note that I left 4&#37; free for margins, borders and the like. That may differ for you depending on the rest of your stylesheet.
    I suspect you've something else on the page that takes up >4% of the width. Lower the numbers, or use percentages to specify the width of that as well.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  5. #5
    Join Date
    Apr 2006
    Posts
    27
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    I am using a blank page to test the code so there is nothing else there and no matter what the percentage is the after the left text there is a break

  6. #6
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Hmm... where is this page?
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  7. #7
    Join Date
    Apr 2006
    Posts
    27
    Thanks
    0
    Thanked 0 Times in 0 Posts

  8. #8
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Looks fine here in Konqueror and Firefox.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  9. #9
    Join Date
    Apr 2006
    Posts
    27
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    hmm that's strange then, i am using firefox and it appears to have a line break after the left text

  10. #10
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Hm, I see it in Firefox 2 but not a3 or Konqueror. Possibly a Fx2 bug?
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

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
  •