PHP Developers Network

A community of PHP developers offering assistance, advice, discussion, and friendship.
 
Loading
It is currently Tue Oct 20, 2020 4:01 am

All times are UTC - 5 hours




Post new topic Reply to topic  [ 6 posts ] 
Author Message
PostPosted: Sun Oct 12, 2014 6:24 pm 
Offline
Forum Contributor

Joined: Fri Jun 11, 2010 1:17 pm
Posts: 214
Hi everyone:
I've searched the net for quite a while but haven't found a solution to my issue so I thought I'd post my coding here to see if anyone could recommend a solution.

I need text to wrap within a cell, but I've found that some text goes outside the line and does not wrap. Any help would be appreciated. Thanks.

the css I use is:
td {
display: table-cell;
}

Then on the table and cell, I use:

Syntax: [ Download ] [ Hide ]
echo "<table cellpadding='10' width='900' style='border-collapse:collapse;table-layout:fixed'>"
echo '<td valign="top" style="white-space:pre-wrap;white-space:-moz-pre-wrap !important;white-space:-pre-wrap;white-space:-o-pre-wrap;word-wrap:break-word;word-break:normal; width:99%; overflow-x:auto;">' . $result['description'] . '</td>';
 


Top
 Profile  
 
PostPosted: Mon Oct 13, 2014 2:58 am 
Offline
Forum Contributor

Joined: Fri Nov 07, 2008 6:31 am
Posts: 230
Location: Nashik, India
use PHP wordwrap() function instead

Syntax: [ Download ] [ Hide ]
e.g.
$newtext = wordwrap($text, 20, "<br />\n");
 

_________________
|


Top
 Profile  
 
PostPosted: Mon Oct 13, 2014 2:02 pm 
Offline
Forum Contributor

Joined: Fri Jun 11, 2010 1:17 pm
Posts: 214
so you think i should replace all of this: style="white-space:pre-wrap;white-space:-moz-pre-wrap !important;white-space:-pre-wrap;white-space:-o-pre-wrap;word-wrap:break-word;word-break:normal; width:99%; overflow-x:auto;" with just the php wordwrap?


Top
 Profile  
 
PostPosted: Mon Oct 13, 2014 2:51 pm 
Offline
Moderator
User avatar

Joined: Tue Nov 09, 2010 3:39 pm
Posts: 6425
Location: Montreal, Canada
No. That wraps a string at a fixed number of characters which is not only unhelpful for variable width fonts, but not great for responsive either. Can you show an example of the problem on JSFiddle or Codepen or something?

_________________


Top
 Profile  
 
PostPosted: Mon Oct 13, 2014 2:51 pm 
Offline
Moderator
User avatar

Joined: Tue Nov 09, 2010 3:39 pm
Posts: 6425
Location: Montreal, Canada
Also, isn't there a <tr> missing in there?

_________________


Top
 Profile  
 
PostPosted: Mon Oct 13, 2014 3:33 pm 
Offline
Forum Contributor

Joined: Fri Jun 11, 2010 1:17 pm
Posts: 214
i only gave you the lines of code which i was inquiring about. i just omitted the tr's


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 5 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group