GIDForums  

Go Back   GIDForums > Webmaster Forums > Web Design Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 25-Feb-2009, 13:37
toonarific toonarific is offline
New Member
 
Join Date: Jan 2004
Posts: 3
toonarific is on a distinguished road
Exclamation

Preformatting tag issues


ok, I have a pm system on my site which I have been working on a little today. it all works fine, but when I try and format the read message page, it isnt working as Id like

when I read a message, it pulls the content from the sql table and displays it, as usual. now, when I dont add the <pre> tag it reads like


Quote:
thanks alot!***user1: did you get it?***user2: how about the cat picture?


but when I use the <pre> tag it displays correctly


Quote:
thanks alot!
***user1: did you get it?
***user2: how about the cat picture?


the only issue with using the <pre> tag is that it doesnt allow the wordwrap (that I know of). if a line is longer than the table layout, it will stretch the cell way out to the right and the page will get skewed.

is there an alternative to the <pre> tag that will keep the formatting of the table when it calls it from the db, or a way to properly wrap text within a <pre> tag set?

Thanks in advance for your help.
  #2  
Old 25-Feb-2009, 19:29
admin's Avatar
admin admin is offline
Administrator
 
Join Date: Sep 2002
Posts: 841
admin will become famous soon enough

Re: Preformatting tag issues


We discussed something similar a few days ago: http://www.gidforums.com/t-20670.html.

When I use the <pre> tags to display code examples here, I use Cascading Stylesheets (CSS) width and overflow properties to control that a really long line of text does not stretch the overall layout of the page. Here is an example:

CSS Code:
pre.mychat
{
	border:1px solid gray;
	width:612px;
	overflow:auto;
}

HTML Code:
<pre class="mychat" style="height:42px;">thanks alot! ***user1: did you get it? ***user2: how about the cat picture? </pre>

It is important that you set the (CSS) height property value inline (with a style attribute) because if you have multiple "chat" transcripts to display, with variable lengths, you can simply count the number of newlines (and carriage returns) for each and set the height accordingly. Beyond a certain number of newlines, you simply set a fixed height, say 460px, so the reader finds it easier to scroll.
__________________
Custom BB codes you can use here:
[HTML] | [C++] | [CSS] | [JAVA] | [PY] | [VB]
  #3  
Old 25-Feb-2009, 20:02
toonarific toonarific is offline
New Member
 
Join Date: Jan 2004
Posts: 3
toonarific is on a distinguished road

Re: Preformatting tag issues


Ok, thanks. Ill try that. I did a ton of reading around today and it seems to be more of a major issue with IE6 & 7, regarding <pre> in a table cell and maintaining wordwrap. I found a site that gives a good CSS snip for pre, but it still doesnt affect IE6 or 7. If you know a sure fire solution to having wordwrap apply to pre in a table cell, Im all ears...definitely. I couldnt find anything anywhere that helped.
  #4  
Old 25-Feb-2009, 20:56
admin's Avatar
admin admin is offline
Administrator
 
Join Date: Sep 2002
Posts: 841
admin will become famous soon enough

Re: Preformatting tag issues


When you say "wordwrap", I assume you want to split a line (or a really long word) with server-side functions such as the one supplied by PHP?

You could do that but then you will be adding to your problems because NEW newlines could be inserted in your final text by the function. You could remove all newlines before processing the text through PHP's wordwrap() function but then that would also add new problems for you to solve.

The simplest solution is what I mentioned above i.e. controlling the overflowing content through CSS. When I worked on the code example displays for this forum for the first time, it was way back in 2003, and at the time I am sure I was using Internet Explorer 6.

I remember that the CSS overflow property didn't work with IE6 unless I set the width property too, which is why I mentioned it in my post. With Firefox, the width was not necessary and it will be relative to the previous tag's width.

Your best bet would be to follow my suggestion above.

If you find another equally simple solution, I hope you will share it with us.
__________________
Custom BB codes you can use here:
[HTML] | [C++] | [CSS] | [JAVA] | [PY] | [VB]
  #5  
Old 25-Mar-2009, 10:48
MisterChucker's Avatar
MisterChucker MisterChucker is offline
Junior Member
 
Join Date: Mar 2009
Location: Cyberspace, Earth
Posts: 53
MisterChucker is a jewel in the roughMisterChucker is a jewel in the roughMisterChucker is a jewel in the rough

Re: Preformatting tag issues


How about a textarea? It wraps long lines automatically. If you add some style, you can make it look more like a pre.
HTML Code:
<textarea style="width: 100%; border: 0;" readonly="readonly">thanks alot! ***user1: did you get it? ***user2: how about the cat picture? </textarea>
One down-side is that, unlike the pre, the textarea will always have a vertical scroll bar in Internet Explorer even its height exceeds the content's height.
 
 

Recent GIDBlogProgramming ebook direct download available by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Is this how our leaders fix nation's most important issues? poppyyo8 Open Discussion Forum 1 24-Mar-2008 10:13
Windows Updates and Secure Website Issues LocalTech Computer Software Forum - Windows 0 31-Jul-2007 05:30
Graphics Issues (Screenshots Included) NovaTiger Computer Hardware Forum 2 03-Apr-2007 18:16
Streamyx (DSL) and Windows ME issues. JdS Computer Software Forum - Windows 4 03-Apr-2004 05:15
Downloadable document compatibilty issues? rhino1616 Web Design Forum 3 07-May-2003 04:05

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 06:21.


vBulletin, Copyright © 2000 - 2009, Jelsoft Enterprises Ltd.