简体   繁体   English

制作<textarea>填充表格单元格的高度

[英]Make <textarea> fill table cell's height

I use the following code to create a table with an image and a <textare> :我使用以下代码创建一个带有图像和<textare>的表格:

<table border="1" style="border-color: #a6a6a6" cellpadding="4" cellspacing="0" width="702">\
  <col width="455">
  <col width="230">\
  <tbody>
    <tr>\
      <td type="image" id="' + sdfsdsdf + '" data-parent-id="0" data-type="NORMAL" data-img="1" data-flags="1" data-type-ios="3" height="85" width="455"><img src="http://www.whichcitytotravel.com/wp-content/uploads/2016/01/Sunset-in-Monaco.jpg" style="width:100%;"></td>\
      <td width="230">
        <pre><textarea id="' + sdfsdfsdaf + '" data-parent-id="' + id_picture + '" data-type="sdfsdafsd" data-type-ios="4" rows="5" style="width:100%; height:100%; display:block;"></textarea></pre><br></td>\
    </tr>
  </tbody>
</table>'

The result looks like this: https://jsfiddle.net/705buxgz/结果如下所示: https : //jsfiddle.net/705buxgz/

I'd like the <textarea> to fill all the height available inside the cell of the table.我希望<textarea>填充表格单元格内的所有可用高度。

I tried all the other answers here and none of them worked for me.我在这里尝试了所有其他答案,但没有一个对我有用。

This should do the trick: https://jsfiddle.net/cLro4q10/这应该可以解决问题: https : //jsfiddle.net/cLro4q10/

You have to set the table and pre height.您必须设置tablepre高度。 In this case I made it 100%.在这种情况下,我做到了 100%。 A child can only be 100% height of its parent if the parents' height has been set.如果已经设置了父母的身高,孩子只能是父母身高的 100%。

I don't know if this will work for everyone, and that's because I found it in my CSS.我不知道这是否适用于每个人,那是因为我在我的 CSS 中找到了它。 In my Site.css file I found the following:在我的 Site.css 文件中,我发现了以下内容:

input,
select,
textarea {
    max-width: 280px;
}

Once I removed it my textarea filled the cell.一旦我删除它,我的 textarea 填充了单元格。 But once again, that was just because of my CSS.但再一次,那只是因为我的 CSS。 I removed the reference to "textarea" so it looks like我删除了对“textarea”的引用,所以它看起来像

input,
select {
    max-width: 280px;
}

and now it works.现在它起作用了。

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

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