我想将一个 div 的宽度和高度值自动设置为与表格的单元格相同。
表列 <td>
将是动态宽度和高度。
Purpose : User have to click each cell of table.
比方说,
<table>
<tr>
<td> <-------- dynamic width & height
<commandLink>
<div> <---------- I cannot click this <div> as link, can you provide me?
//nod ata
</div>
</commandlink>
</td>
</tr>
</table>
最佳答案
只需申请
td div {
width: 100%;
height : 100%;
}
但您需要为 td
指定高度元素。
无论如何,默认情况下,div 已经适合整个宽度,所以 height: 100%
够了。
如果您的 div 必须是可点击的,您可以附加一个 <a>
使用以下样式在 div 中标记
td div#your-id a {
display : block;
width: 100%;
height : 100%;
}
或者您为 onclick
附加一个处理程序通过 JavaScript 将事件发送到 div。
关于css - DIV 的 Width & Height CSS 样式与其容器表格列相同,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12619536/