adore Posted February 18, 2008 Share Posted February 18, 2008 Am hoping one of you experts can help me with what will no doubt be a simple matter to you.I’m trying to restrict word wrapping in a table. I have defined a style with the whitespaces : nowrap option set, but it doesn’t seem to have any affect on the table. I include the relevant code sections below. Can anybody please help?<style> .firstline {white-space: nowrap; background-color: white; color: black; font-size = 11;} .secondline {white-space: nowrap; background-color: rgb(225,224,238); color: black; font-size = 11;} </style>PHP codeif (blurd..............) {$row_class = "firstline";} else {$row_class = "secondline";} echo "<tr class = $row_class>";The other formatting elements work correctly, except the nowrap option. Link to comment Share on other sites More sharing options...
adore Posted February 18, 2008 Author Share Posted February 18, 2008 An obvious “work around” for this problem is to truncate the entry prior to display. However, the problem is that a truncated entry is less visually appealing, as you may see an obviously truncated entry which does not fill the column (due to character spacing variations.) NOWRAP is clearly the solution, but what I’ve done wrong is not. Link to comment Share on other sites More sharing options...
jeffman Posted February 18, 2008 Share Posted February 18, 2008 Exactly what effect are you going for? A table that runs on and on to the right until it runs out of content? That's what no-wrap does.BTW, is this a table for true tabular data, or are you using the table for layout design? If the latter, divs are generally preferred and may give you a better chance to get what you're after. Link to comment Share on other sites More sharing options...
adore Posted February 18, 2008 Author Share Posted February 18, 2008 Exactly what effect are you going for? A table that runs on and on to the right until it runs out of content? That's what no-wrap does.BTW, is this a table for true tabular data, or are you using the table for layout design? If the latter, divs are generally preferred and may give you a better chance to get what you're after.The table is for data display purposes. The colum width is set, so as a result, I'm getting word wrapping on certain enteries. I don't want the overall table size to keep changing as I page through the data set. As I understand it, NOWRAP would not exceed column width and as a result truncate itself at this point. Link to comment Share on other sites More sharing options...
jeffman Posted February 19, 2008 Share Posted February 19, 2008 . . . NOWRAP would not exceed column width and as a result truncate itself at this point.Uh-uh. With a fixed-width cell and white-space set to normal, the content would wrap and adjust the height to fit the content. With whitespace set to no-wrap, the cell width just increases. Neither of these is what you want.That's normally.But I've discovered a few more tricks. I've written the style declarations generically, but you'll see what you need to do:table {table-layout:fixed;} td {overflow:hidden; white-space:nowrap; width:90px} That should do it. Link to comment Share on other sites More sharing options...
adore Posted February 19, 2008 Author Share Posted February 19, 2008 Uh-uh. With a fixed-width cell and white-space set to normal, the content would wrap and adjust the height to fit the content. With whitespace set to no-wrap, the cell width just increases. Neither of these is what you want.That's normally.But I've discovered a few more tricks. I've written the style declarations generically, but you'll see what you need to do:table {table-layout:fixed;} td {overflow:hidden; white-space:nowrap; width:90px} That should do it. Thank you for your help!Much appreciated! Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.