css - How to force table cell content to wrap? -
css - How to force table cell <td> content to wrap? -
heres entire page * wrappable definded in main.css file
/* wrappable cell * add together class create sure text in cell wrap. * default, data_table tds not wrap. */ td.wrappable, table.data_table td.wrappable { white-space: normal; }
heres entire page:
<%@ include file="../../include/pre-header.html" %> <form id="commentform" name="commentform" action="" method="post"> <ctl:vertscroll height="300" headerstyleclass="data_table_scroll" bodystyleclass="data_table_scroll" enabled="${user.scrolltables}"> <ctl:sortabletblhdrsetup toptotal="false" href="show.whatif_edit_entry? entryid=${entry.entryid}"/> <table class="data_table vert_scroll_table"> </tr> <tr> <ctl:sortabletblhdr styleclass="center" title="comments" property="comment" type="top">comments</ctl:sortabletblhdr> </tr> <c:foreach var="comments" items="${entry.comments}"> <tr id="id${comments.id}"> <td id="comments-${comments.id}" class="wrappable" style="width:400px;">${comments.comment}</td> </tr> </c:foreach> <c:if test="${lock.locked || form.entryid < 0 }"> <%-- row adding new comment. --%> <tr id="commentrow"> <td><input type="text" id="comment" name="comment" size="50" maxlength="250" onkeypress="javascript:return noenter();"/> <a href="javascript:addcomment();"><img src="../images/icon_add.gif" border="0" alt="add"/></a> </td> </tr> </c:if>
it stretches everytime submit. page within div also. need set width of div , table also?
use table-layout:fixed
in table , word-wrap:break-word
in td.
see example:
<html> <head> <style> table {border-collapse:collapse; table-layout:fixed; width:310px;} table td {border:solid 1px #fab; width:100px; word-wrap:break-word;} </style> </head> <body> <table> <tr> <td>1</td> <td>lorem ipsum</td> <td>lorem ipsum dummy text of printing , typesetting industry. </td> </tr> <tr> <td>2</td> <td>loremipsumhasbeentheindustry'sstandarddummytexteversincethe1500s,whenanunknown</td> <td>lorem ipsum has been industry's standard dummy text ever since 1500s, when unknown printer took galley of type , scrambled create type specimen book.</td> </tr> <tr> <td>3</td> <td></td> <td>lorem ipsum dolor sit down amet, consectetur adipisicing elit, sed eiusmod tempor incididunt ut labore et dolore magna...</td> </tr> </table> </body> </html>
demo: class="snippet-code-css lang-css prettyprint-override">table {border-collapse:collapse; table-layout:fixed; width:310px;} table td {border:solid 1px #fab; width:100px; word-wrap:break-word;}
class="snippet-code-html lang-html prettyprint-override"> <table> <tr> <td>1</td> <td>lorem ipsum</td> <td>lorem ipsum dummy text of printing , typesetting industry. </td> </tr> <tr> <td>2</td> <td>loremipsumhasbeentheindustry'sstandarddummytexteversincethe1500s,whenanunknown</td> <td>lorem ipsum has been industry's standard dummy text ever since 1500s, when unknown printer took galley of type , scrambled create type specimen book.</td> </tr> <tr> <td>3</td> <td></td> <td>lorem ipsum dolor sit down amet, consectetur adipisicing elit, sed eiusmod tempor incididunt ut labore et dolore magna...</td> </tr> </table>
css table html
Comments
Post a Comment