milorules1012 milorules1012 - 5 months ago 8
CSS Question

Size CSS button to HTML border

I have been making a website, and I created a few buttons. Recently I have used css "padding" to size the buttons to be equal in size to each other. What I am wondering is, is there a way that I can size the button to fit with the table border, so it can look nice in any resolution size browser?

Here is a screenshot of my site so you guys know what you're looking at

Answer

Give button a width:100% and the td a padding: 0

table {
  width: 200px;
}
td {
  border: 1px solid;
  padding: 0;
}
button {
  width: 100%;
}
<table>
  <tr>
    <td>
      <button>Button</button>
    </td>
  </tr>
</table>

Comments