Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New to the CF scene
    Join Date
    Oct 2006
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    controling <pre> width

    I have text that is formated with <pre> going in to a <div> which has its width constrained to 80%. If I want the text not to bust through the <div> and streem endlessly right, what should I do?

    -Thanks!

  • #2
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,609
    Thanks
    0
    Thanked 645 Times in 635 Posts
    You could set overflow:hidden or overflow:scroll for the pre tag. The first will hide what wont fit while the second will add a scrollbar to the pre tag when it is needed.
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.

  • #3
    Senior Coder
    Join Date
    Dec 2004
    Location
    Essex, UK
    Posts
    2,636
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Have you tried giving the <pre> a width (possibly of 80%) too?

  • #4
    New to the CF scene
    Join Date
    Oct 2006
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    the thing is, that I want the text to form a column, as one might do by placing it inside a div.

    I tryed the width on the pre tag itsef already, didnt do anything.

    Any other ideas?

  • #5
    Senior Coder Arbitrator's Avatar
    Join Date
    Mar 2006
    Location
    Splendora, Texas, United States of America
    Posts
    3,300
    Thanks
    28
    Thanked 275 Times in 269 Posts
    I'm guessing that you want new-line and white-space formatting to be preserved but for wrapping to also occur? You would use white-space: pre-wrap for that. Support for it is pretty poor though.

    Resources:
    For every complex problem, there is an answer that is clear, simple, and wrong.

  • #6
    New to the CF scene
    Join Date
    Oct 2006
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Ahh it worked!

    Code:
    pre{
    	font-family:Georgia, "Times New Roman", Times, serif;
    	white-space: pre; /* CSS2 */
    	white-space: -moz-pre-wrap; /* Mozilla */
    	white-space: -hp-pre-wrap; /* HP printers */
    	white-space: -o-pre-wrap; /* Opera 7 */
    	white-space: -pre-wrap; /* Opera 4-6 */
    	white-space: pre-wrap; /* CSS 2.1 */
    	white-space: pre-line; /* CSS 3 (and 2.1 as well, actually) */
    	word-wrap: break-word; /* IE */
    	}
    that setup gleened off one of your resources did the trick.
    Thanks!


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •