将文本排成相同的高度可以通过以下几种方法实现:
<div class="container">
<div class="text-block">文本1</div>
<div class="text-block">文本2</div>
<div class="text-block">文本3</div>
</div>
<style>
.container {
display: flex;
align-items: stretch;
}
.text-block {
border: 1px solid #000;
flex: 1;
}
</style>
推荐的腾讯云相关产品:腾讯云云服务器(CVM),产品介绍链接地址:https://cloud.tencent.com/product/cvm
<div class="text-block">文本1</div>
<div class="text-block">文本2</div>
<div class="text-block">文本3</div>
<script>
var textBlocks = document.getElementsByClassName('text-block');
var maxHeight = 0;
for (var i = 0; i < textBlocks.length; i++) {
if (textBlocks[i].offsetHeight > maxHeight) {
maxHeight = textBlocks[i].offsetHeight;
}
}
for (var i = 0; i < textBlocks.length; i++) {
textBlocks[i].style.height = maxHeight + 'px';
}
</script>
推荐的腾讯云相关产品:腾讯云云函数(SCF),产品介绍链接地址:https://cloud.tencent.com/product/scf
<table>
<tr>
<td>文本1</td>
</tr>
<tr>
<td>文本2</td>
</tr>
<tr>
<td>文本3</td>
</tr>
</table>
推荐的腾讯云相关产品:腾讯云云数据库MySQL版(TencentDB for MySQL),产品介绍链接地址:https://cloud.tencent.com/product/cdb_mysql
领取专属 10元无门槛券
手把手带您无忧上云