简体   繁体   English

防止td中的跨度满足

[英]prevent span in td contenteditable

I use contenteditable in td 我在td中使用contenteditable

<table style="width:200px">
<tr>
    <td contenteditable  style="width:100px" id="1">test</td>
    <td contenteditable  style="width:100px" id="2">test</td>
</tr>
</table>

when I enter more text in the first td, it make the second td become smaller, then table will bigger than 200px that I specified before, how can I prevent that ? 当我在第一个td中输入更多文本时,它会使第二个td变小,然后表格将大于我之前指定的200px,我该如何防止?

Try this: 尝试这个:

<table style="max-width:200px;">
<tr>
    <td contenteditable="true" style="max-width:100px; word-wrap: break-word;" id="1">test</td>
    <td contenteditable="true"  style="width:100px;" id="2">test</td>
</tr>
</table>

http://jsfiddle.net/8ZNj3/1/ http://jsfiddle.net/8ZNj3/1/

html: HTML:

<table>
    <tr>
        <td contenteditable>this long text won't overflow</td>
        <td contenteditable>test</td>
    </tr>
</table>

css: CSS:

table {
    width: 200px;
    table-layout: fixed;
}
td {
    width: 100px;
    white-space: nowrap;
    overflow: hidden;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM