SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Wizard WorldNews's Avatar
    Join Date
    Nov 2007
    Posts
    1,033
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    How to get all pages lined up the same?

    Hello,

    We offer a free Blog service which is developed in PHP & MySQL.
    Of course this Blog displays pages of text submitted by users to their blogs.
    Problem I am trying to solve is how to get each page to uniformly display the text with the same width? So that the text is not jotting all over the place on the right side of the page.

    As you can see in this example:
    http://www.anoox.com/news/show_selec...?article=34476

    So is there a function or snipet of code that you can suggest which will cause all the text to be right aligned the same unless of course the user manually inserts a break at a certain line.

    Regards,

    Anoox search engine volunteer

    www.anoox.com

  2. #2
    SitePoint Addict Mal Curtis's Avatar
    Join Date
    Jul 2009
    Location
    New Zealand
    Posts
    327
    Mentioned
    13 Post(s)
    Tagged
    0 Thread(s)
    There are plenty of <br> tags in there which are causing the line widths to be variable.

    What you really want to do is make the text area a fixed width, say 500px, and then set the text to 'text-align: justify' in css.

    If you have no control over the <br /> tags, then you can use a str_replace() call to get rid of any <br> or <br /> tags.

  3. #3
    SitePoint Wizard WorldNews's Avatar
    Join Date
    Nov 2007
    Posts
    1,033
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Hello,

    I am not quite following you!
    What do you mean exactly by:
    'text-align: justify' in css?
    Exactly what is the code for this and is it in form of a class I assume?

    Also what do you mean exactly by:
    str_replace()
    keeping in mind that we do not want to remove the user (intentionally) entered break lines, in case for whatever reason they want to have extra
    brs in their Blog, etc.

    Regards,

    Quote Originally Posted by Mal Curtis View Post
    There are plenty of <br> tags in there which are causing the line widths to be variable.

    What you really want to do is make the text area a fixed width, say 500px, and then set the text to 'text-align: justify' in css.

    If you have no control over the <br /> tags, then you can use a str_replace() call to get rid of any <br> or <br /> tags.

    Anoox search engine volunteer

    www.anoox.com

  4. #4
    SitePoint Addict Mal Curtis's Avatar
    Join Date
    Jul 2009
    Location
    New Zealand
    Posts
    327
    Mentioned
    13 Post(s)
    Tagged
    0 Thread(s)
    The css would apply to the area where you have your text, in your case you have a class of blog_text so you could add it in there

    e.g.

    Code CSS:
    .blog_text{
     /* existing styles here */
     text-align:justify;
    }

    This will make a paragraph of text align to the full width of the space it's in. However a lot of the content on the page you linked to is using <br> tags to line up new lines.

    For example
    Code HTML4Strict:
    So this  Demint and people like him either they are so unaware or they are so bought by Big pharma,<br />
    Big insurance, etc. to not face the fact that it is not Obama's Waterloo if we do not pass Universal health care<br />
    in this country, but it is the waterloo of American people and businesses if we do not. After all:<br  />

    Because you don't want to remove those br tags, there's nothing you can do to prevent the text from not reaching the width of the element it is inside.

  5. #5
    SitePoint Wizard WorldNews's Avatar
    Join Date
    Nov 2007
    Posts
    1,033
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Hello,

    I applied your suggestion for the CSS. that is added this:
    text-align:justify;

    however the text alignment on the right side is still all over the place!

    You see this is a free Blog service so people can post what they want and
    of course we have very little control whether they insert break lines in the body of their Blog or not, also different screen sizes causes text to wrap in different ways when you are entering your text. So I was hoping there was a way of smoothing out all Blog entries to be right justified no matter what they entered.

    Regards,


    Quote Originally Posted by Mal Curtis View Post
    The css would apply to the area where you have your text, in your case you have a class of blog_text so you could add it in there

    e.g.

    Code CSS:
    .blog_text{
     /* existing styles here */
     text-align:justify;
    }

    This will make a paragraph of text align to the full width of the space it's in. However a lot of the content on the page you linked to is using <br> tags to line up new lines.

    For example
    Code HTML4Strict:
    So this  Demint and people like him either they are so unaware or they are so bought by Big pharma,<br />
    Big insurance, etc. to not face the fact that it is not Obama's Waterloo if we do not pass Universal health care<br />
    in this country, but it is the waterloo of American people and businesses if we do not. After all:<br  />

    Because you don't want to remove those br tags, there's nothing you can do to prevent the text from not reaching the width of the element it is inside.

    Anoox search engine volunteer

    www.anoox.com

  6. #6
    SitePoint Evangelist Waffles's Avatar
    Join Date
    Nov 2005
    Posts
    435
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    can you elaborate with
    however the text alignment on the right side is still all over the place
    ?

    The example page you linked is fully justified, as you would expect, except for the numbered list of points, but the user has entered <br> for some reason mid sentence, which is why it is leaving a large gap.

  7. #7
    SitePoint Addict Mal Curtis's Avatar
    Join Date
    Jul 2009
    Location
    New Zealand
    Posts
    327
    Mentioned
    13 Post(s)
    Tagged
    0 Thread(s)
    As I said earlier, you will HAVE to remove the BR tags that the user has entered, but you've stated you won't remove the user BR tags. Therefore you cannot do what you want.

    Just remove the BR tags


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
  •