I am trying to create an HTML 'numeric keypad', like those found on some keyboards. I am stumped on how to do the layout without using a table.
I am using Bootstrap (v3.1.1) so my first instinct was to attempt to use its col-
classes to reproduce the 4 columns of keys found on a keypad. This was awkward though and I couldn't easily get the sizing of the buttons to be consistent between the different levels of nested div
containers. I failed fast.
I knew I could use a <table>
based layout to accomplish this easily with colspan
s and rowspan
s. But it didn't feel right using a table layout for this, because it is clearly not tabular data.
I tried to get the benefits of tables by using the CSS display
property's table*
values. This was cleaner than my first attempt and the classes I used were more meaningful than the Bootstrap ones I was attempting to use before. Unfortunately, I learned that display:table
does not support colspan/rowspan. Here is a JSFiddle of that attempt. I tried to fake a rowspan
on the tall-key
s by using height: 144px;
but that just increased the height of the entire row.
I gave up and ultimately created the layout with a <table>
. Here is the JSFiddle.
Is there a way to create a numeric keypad without using an HTML <table>
?
Note: The heights of keys can be static values (e.g. 70px
) but the widths cannot. The width of the entire keypad
is a variable percentage of the container, because responsive.