简体   繁体   English

如何限制高度 <tr> 如果里面有文字区域 <td>

[英]How to restrict the height of <tr> if there is a text area inside <td>

I have a html table with following structure 我有一个具有以下结构的html表

<table>
<tr class="border_bottom">
  <td><input type="text"></td>
  <td><input type="text"></td>
  <td><input type="text"></td>
  <td><textarea></textarea></td>
</tr>
</table>

Thje height of text area is flexible. 文本区域的高度是灵活的。 My problem is the wrapper tr/td height should not be increased as per the text area. 我的问题是包装纸的tr / td高度不应根据文本区域增加。

I want tr/td height constant and text area height should be overflow the td 我想要tr / td高度常数并且文本区域高度应该溢出td

Unfortunately I dont have the liberty to change html. 不幸的是,我没有更改html的自由。 I am looking for a solution purely based on css. 我正在寻找纯粹基于CSS的解决方案。

Code: https://jsfiddle.net/5u1mk39t/2/ 代码: https//jsfiddle.net/5u1mk39t/2/

Is this closer to what you're after? 这更接近您的追求吗? Edited for jQuery wrap function. 为jQuery wrap函数编辑。

 $("textarea").wrap("<div class='with-textarea'></div>"); 
 tr.border_bottom td { border: 1pt solid black; } tr.border_bottom td textarea { width: 200px; } .with-textarea { height: 55px; } textarea { resize: vertical; } 
 <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <table> <tr class="border_bottom"> <td> <input type="text"> </td> <td> <input type="text"> </td> <td> <input type="text"> </td> <td> <textarea></textarea> </td> </tr> </table> 

Try this 尝试这个

    <style>
tr.border_bottom td {
  border:1pt solid black;
}
tr.border_bottom td textarea{
 width:200px; 
 max-height: 55px; 
}
</style>
<table>
<tr class="border_bottom">
  <td><input type="text"></td>
  <td><input type="text"></td>
  <td><input type="text"></td>
  <td><textarea></textarea></td>
</tr>

</table>

Try and put a 尝试把

max-height: xx px;

on the text area style / class 在文本区域的样式/类

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

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