Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Div Text Wrapping

Status
Not open for further replies.

Mham2k

Programmer
Jun 1, 2007
12
US
I am generating html from an xml document sent back from a sql server using xslt. Its going into a div but my div keeps expanding to the right when I need the text to wrap inside the div. I dont want to use a table but if I have to so be it. Thanks for any help.
The div is absolute with a z-index of 5
<div id="Doc" style="left: 520px; top: 128px; height: 475px; width: 408px; white-space: normal;">
dddddddddddddddddddddddddddddddddddddddddddddddddddd
</div>
 
Try this CSS:

Code:
#Doc {
	white-space: pre-wrap; /* css-3 */
	white-space: -moz-pre-wrap; /* Mozilla, since 1999 */
	white-space: -pre-wrap; /* Opera 4-6 */
	white-space: -o-pre-wrap; /* Opera 7 */
	word-wrap: break-word; /* Internet Explorer 5.5+ */
}

I can't remember where I got it from, or how successful it was... but I seem to remember it did the job at the time.

Hope this helps,
Dan



Coedit Limited - Delivering standards compliant, accessible web solutions

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
I've tried Billy's solution on FF but it didn't work :(

This works only on IE :

Code:
#doc {

border: 1px solid #000000;
left: 520px;
top: 128px;
height: 475px;
width: 100px;

word-wrap: break-word;
  
}

Since server side scripting is involved, a solution would be to add spaces in words that are too long.
 
BillyRayPreachersSon Works.... I didn't try Sleidia's but thank you for replying to the thread anyway. This saved me alot of useless time on my latest project.
 
Oh sorry to Billy then.
Maybe it was because I didn't declare the doctype.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top