I want all the columns to be together towards the left side of the table, but nothing i do is able to change the gap between the first column and the second(and third) columns. How do i fix this?
<body>
<h1>Calculator</h1>
<table class="my-table">
<tr>
<td><input type="text"></td>
</tr>
<tr>
<td><input type="button" value="1"></td>
<td><input type="button" value="2"></td>
<td><input type="button" value="3"></td>
</tr>
<tr>
<td><input type="button" value="4"></td>
<td><input type="button" value="5"></td>
<td><input type="button" value="6"></td>
</tr>
<tr>
<td><input type="button" value="7"></td>
<td><input type="button" value="8"></td>
<td><input type="button" value="9"></td>
</tr>
</table>
</body>
</html>
I’ve tried changing the width of tr and nothing changes.
I’ve tried changing the "tr td:first-child" width and nothing changes.
I’m able to create a border and add background color but for some reason i can’t change the size of the content box (of each first row for the first column)
i figured out that the input on top is what’s affecting my table. I’m still not able to do what i want to do while keeping the input there though.
2
Answers
the containing the element uses colspan="3", which makes it span three columns. This allows the input field to be wider and occupy the entire width of the row, aligning it better with the buttons. This can make the calculator display look more organized and visually appealing.
As @Paulie_D has suggested, using CSS-grids is a more wise and better choice to achieve things like a calculator layout.
Look at this example: