试图让文本WRAP一个表

时间:2011-07-27 17:35:27

标签: html css jsp

enter image description here

继承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;
}

感谢帮助.....:)

1 个答案:

答案 0 :(得分:1)

根据我的经验,除非他们有空间,否则事物不会包裹。在这个例子中,这个人用PHP分隔长字:Example

CSS中还有一个自动换行设置可以打破长篇大论:Sorry for W3Schools =(