JS implements the method of controlling the vertical alignment of table cells

  • 2020-05-19 04:12:11
  • OfStack

This article demonstrates an example of how JS can control the vertical alignment of table cells. Share with you for your reference. The details are as follows:

The code below controls the vertical alignment of the specified cells at the bottom


<!DOCTYPE html>
<html>
<head>
<script>
function valignCell()
{
var x=document.getElementById('myTable').rows[0].cells;
x[0].vAlign="bottom";
}
</script>
</head>
<body>
<table id="myTable" border="1" height="70%">
<tr>
<td>First cell</td>
<td>Second cell</td>
</tr>
<tr>
<td>Third cell</td>
<td>Fourth cell</td>
</tr>
</table>
<form>
<input type="button" onclick="valignCell()"
value="Vertical align cell content">
</form>
</body>
</html>

I hope this article has been helpful to your javascript programming.


Related articles: