试图让文本在表中WRAP

试图让文本在表中WRAP

这是jsp上的代码:

<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>
        <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 }">
        <%-- This is the row for adding a new comment. --%>
        <tr id="commentRow">


         <td>
         You have <strong><span id="commentsCounter">${const['COMMENT_MAX_LENGTH'] - fn:length(commentForm.comment)}</span></strong> characters left.<br/>
            <textarea id="comment" name="comment" rows="2" cols="125" style="width:395px;"
                 onkeypress="characterCounter('commentsCounter',${const['COMMENT_MAX_LENGTH']}, this)"
                 onkeydown="characterCounter('commentsCounter',${const['COMMENT_MAX_LENGTH']}, this)"
                 onkeyup="characterCounter('commentsCounter',${const['COMMENT_MAX_LENGTH']}, this)">
              </textarea>

                    <a href="javascript:addComment();"><img src="../images/icon_add.gif" border="0" alt="Add"/></a>
        </td>
    </tr>


我们有一些可包装的css ...我叫对吗?

td.wrappable,
table.data_table td.wrappable
{
white-space: normal;
}


谢谢您的帮助..... : )

最佳答案

以我的经验,除非它们中有空格,否则它们不会包裹。在此示例中,该家伙在PHP中用空格分隔长词:Example

CSS中还有一个自动换行设置,可以将长单词分开:Sorry for W3Schools =(

关于html - 试图让文本在表中WRAP,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/6848703/

10-09 15:03