joe92 Posted April 18, 2012 Share Posted April 18, 2012 I have a div which is too display text and preserve the white space at the same time. I am using the css declartion white-space:pre-wrap; and setting a width on the div to achieve this. However, if the person enters a newline and submits this, when it is converted to a break line with nl2br and then displayed on screen it is far too big. I have absolutely no idea what is happening. I have attached an image of an example text to demonstrate what is happening. This is the HTML layout: <div id="theMessage$id" class="theMessage"> <div id="pre$id" class="preTag">$message</div> </div> This is the CSS attached too it: .theMessage{ position:relative; display:table-cell; padding:0 0 0 5px; margin:0; } .preTag{ line-height:1em; margin:0; padding:0; min-width:53em; width:53em; max-width:53em; white-space:pre-wrap; white-space: -moz-pre-wrap !important; /* 1999+ Mozilla */ white-space: -pre-wrap; /* Opera 4 thru 6 */ white-space: -o-pre-wrap; /* Opera 7 and up */ word-wrap: break-word; /* IE 5.5+ and up */ } Thanks for any help! Joe P.s. This is the html markup copied and pasted from firebug of the message from the attached image: <div id="theMessage911" class="theMessage"> <div id="pre911" class="preTag"> Here is a large paragraph of text to demonstrate how the newlines are too large. I have no idea what is causing the newlines to become so large but I have a feeling it is the fact that we are preserving white space by using the css, white-space:pre-wrap;. If I now end this paragraph and press enter once the gap will be too large. <br> See? I only pressed enter once. This is really beginning to annoy me. I have tried all sorts of fonts and the problem remains. I have line-height:1em; within my css also. What is happening? </div> </div> Quote Link to comment https://forums.phpfreaks.com/topic/261174-newlinesbreaklines-are-too-large/ Share on other sites More sharing options...
joe92 Posted April 18, 2012 Author Share Posted April 18, 2012 Ok, I have located the problem and it was nothing to do with CSS or HTML. Somehow the message was being run through nl2br twice. I don't even know where the second call is yet. This just adds a bit more confusion but at least the problem is no longer a problem. Joe Quote Link to comment https://forums.phpfreaks.com/topic/261174-newlinesbreaklines-are-too-large/#findComment-1338441 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.