Jump to content

Newlines/Breaklines are too large


joe92

Recommended Posts

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>

post-108745-13482403434231_thumb.png

Link to comment
https://forums.phpfreaks.com/topic/261174-newlinesbreaklines-are-too-large/
Share on other sites

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.