2017-02-21 16 views
-1

Я установил на стол, но слова в каждой ячейке разбиты на новую строку.Как предотвратить разрыв слова в ячейке таблицы фиксированного расположения?

Eg: 

Applicatio 
n 

Instead of: 

Application 

Я попробовать решение, добавив white-space: nowrap; без толка, как suggested here

Вопрос: Как предотвратить разрыв слов в фиксированной верстке ячейке таблицы?

Сервировка стола:

   <table id="escalation" class="table table-striped table-bordered" cellspacing="0"> 


       <thead> 
        <tr> 
         <th style="display:none">ID</th> 
         <th>RID</th> 
         <th>Asset Name</th>  
        </tr> 
       </thead> 
       <tbody> 

         <tr> 
          <td>1</td> 
          <td class="td-limit">102345</td> 
          <td class="td-limit">Application Testing Break</td> 
         </tr> 

       </tbody> 
      </table> 

CSS:

#escalation { 

    table-layout: fixed; 
} 

#escalation th { 
    overflow: auto; 
    font-size: 10px; 
    color: #000000; 
    border-right: 1px solid #7591ac; 
} 
.td-limit { 
    overflow: auto; 
    font-size: 11px; 
    max-width: 220px; 
    overflow: hidden; 
    word-wrap: break-word; 
} 
+0

Вы хотите, чтобы текст разбить где-нибудь в слове? –

+1

Если вы не хотите сломать слово, почему вы установили 'word-wrap: break-word;' также ваш 'table-layout: fixed;' не будет работать без 'width'. – Stickers

ответ

1

Применить CSS word-break:keep-all к ячейкам.

table { width:100px; border:1px solid black; } 
 
th, td { word-break:keep-all; border:1px solid black; }
<table id="escalation" class="table table-striped table-bordered" cellspacing="0"> 
 

 

 
       <thead> 
 
        <tr> 
 
         <th style="display:none">ID</th> 
 
         <th>RID</th> 
 
         <th>Asset Name</th>  
 
        </tr> 
 
       </thead> 
 
       <tbody> 
 

 
         <tr> 
 
          <td>1</td> 
 
          <td class="td-limit">102345</td> 
 
          <td class="td-limit">Application Testing Break</td> 
 
         </tr> 
 

 
       </tbody> 
 
      </table>

+0

Почему бы не ссылку ['CSS' spec] (https://drafts.csswg.org/css-text-3/#word-break-property)? –

+0

@AndreiGheorghiu Почему бы не ссылку на один из определенных ресурсов, который намного легче переварить, чем спецификация.? –

+0

@AndreiGheorghiu ??????????????????????????? –

0

Вам нужно будет добавить white-space: nowrap; к вашему .td-limit

#escalation { 
 

 
    table-layout: fixed; 
 
} 
 

 
#escalation th { 
 
    overflow: auto; 
 
    font-size: 10px; 
 
    color: #000000; 
 
    border-right: 1px solid #7591ac; 
 
} 
 
.td-limit { 
 
    overflow: auto; 
 
    font-size: 11px; 
 
    max-width: 220px; 
 
    overflow: hidden; 
 
    word-wrap: break-word; 
 
    white-space: nowrap; 
 
}
<table id="escalation" class="table table-striped table-bordered" cellspacing="0"> 
 

 

 
    <thead> 
 
    <tr> 
 
     <th style="display:none">ID</th> 
 
     <th>RID</th> 
 
     <th>Asset Name</th> 
 
    </tr> 
 
    </thead> 
 
    <tbody> 
 

 
    <tr> 
 
     <td>1</td> 
 
     <td class="td-limit">102345</td> 
 
     <td class="td-limit">Application Testing Break</td> 
 
    </tr> 
 

 
    </tbody> 
 
</table>

 Смежные вопросы

  • Нет связанных вопросов^_^