테이블 셀 <td> 내용을 강제로 래핑하는 방법은 무엇입니까? <ctl:sortableTblHdrSetup

전체 페이지 * wrappable은 main.css 파일에 정의되어 있습니다.

/* Wrappable cell
* Add this class to make sure the text in a cell will wrap.
* By default, data_table tds do not wrap.
*/
td.wrappable,
table.data_table td.wrappable {
    white-space: normal;
}                

전체 페이지는 다음과 같습니다.

<%@ 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 }">
                <%-- This is the row for adding a 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>

        </table>

    </ctl:vertScroll>
</form>

제출할 때마다 늘어납니다.
이 페이지는 div 내에 있습니다. div와 테이블의 너비도 설정해야합니까?



답변

table-layout:fixed테이블과 word-wrap:break-wordtd에서 사용하십시오 .

이 예를보십시오 :

<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 is simply dummy text of the printing and typesetting industry. </td>
      </tr>
      <tr>
         <td>2</td>
         <td>LoremIpsumhasbeentheindustry'sstandarddummytexteversincethe1500s,whenanunknown</td>
         <td>Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.</td>
      </tr>
      <tr>
         <td>3</td>
         <td></td>
         <td>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna...</td>
      </tr>
   </table>
</body>
</html>

데모:

table {border-collapse:collapse; table-layout:fixed; width:310px;}
       table td {border:solid 1px #fab; width:100px; word-wrap:break-word;}
       <table>
          <tr>
             <td>1</td>
             <td>Lorem Ipsum</td>
             <td>Lorem Ipsum is simply dummy text of the printing and typesetting industry. </td>
          </tr>
          <tr>
             <td>2</td>
             <td>LoremIpsumhasbeentheindustry'sstandarddummytexteversincethe1500s,whenanunknown</td>
             <td>Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.</td>
          </tr>
          <tr>
             <td>3</td>
             <td></td>
             <td>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna...</td>
          </tr>
       </table>
    

답변

그것은 나를 위해 작동합니다.

<style type="text/css">

 td {

    /* css-3 */
    white-space: -o-pre-wrap;
    word-wrap: break-word;
    white-space: pre-wrap;
    white-space: -moz-pre-wrap;
    white-space: -pre-wrap;

}

그리고 테이블 속성은 다음과 같습니다

table {
  table-layout: fixed;
  width: 100%
}

답변

td {
overflow: hidden;
max-width: 400px;
word-wrap: break-word;
}

답변

Bootstrap 반응 형 테이블을 사용하는 경우 특정 열의 최대 너비를 설정하고 텍스트 줄 바꿈을 수행하여 다음과 같이이 열의 스타일을 지정하십시오.

max-width:someValue;
word-wrap:break-word

답변

이것은 셀에 “pretty”JSON을 표시해야 할 때 효과적이었습니다.

td { white-space:pre }

white-space속성 에 대한 자세한 내용 :

  • normal :이 값은 사용자 에이전트가 일련의 공백을 축소하고 행 상자를 채우는 데 필요한대로 행을 끊도록 지시합니다.

  • pre:이 값은 사용자 에이전트가 공백 시퀀스를 접는 것을 방지합니다.
    줄 바꿈 문자 만 유지하면 줄이 끊어집니다.

  • nowrap:이 값은에서와 같이 공백을 축소 normal하지만 텍스트 내에서 줄 바꿈을 억제합니다.

  • pre-wrap:이 값은 사용자 에이전트가 공백 시퀀스를 접는 것을 방지합니다.
    줄 바꿈 문자는 유지되며 줄 상자를 채우는 데 필요합니다.

  • pre-line:이 값은 사용자 에이전트가 일련의 공백을 축소하도록 지시합니다.
    줄 바꿈 문자는 유지되며 줄 상자를 채우는 데 필요합니다.

(또한 소스 에서 자세한 내용을 참조하십시오 .)


답변

word-break: break-word; 테이블 클래스에 추가하십시오 .


답변

열을 수정하려면 너비를 설정해야합니다. 예를 들면 다음과 같습니다.

<td style="width:100px;">some data</td>