I am trying to display the full calculator but its not showing middle row:
Its giving me below output:
But if I change the below line:
<td rowspan="1">
<input id="buttonEnter" type="button" class="calcButton" value="enter" />
</td>
It then show me full calculator but small enter button:
I understand that it looks rowspan is applying to all row but how to stop this,
{
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
box-sizing: border-box;
}
/* reset rules */
html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
b, u, i, center,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td,
article, aside, canvas, details, embed,
figure, figcaption, footer, header, hgroup,
menu, nav, output, ruby, section, summary,
time, mark, audio, video {
margin: 0;
padding: 0;
border: 0;
font-size: 100%;
font: inherit;
vertical-align: baseline;
}
/* HTML5 display-role reset for older browsers */
article, aside, details, figcaption, figure,
footer, header, hgroup, menu, nav, section {
display: block;
}
body {
line-height: 1;
width: 960px;
background: white;
margin: 30px auto;
font-family: Verdana, Geneva, sans-serif;
position: relative;
}
ol, ul {
list-style: none;
}
/* page header */
header {
background: #330570;
width: 100%;
color: #FFFFFF;
font-size: 48px;
text-align: center;
line-height: 1.5em;
}
/* main content */
article {
width: 960px;
height: 450px;
text-align: left;
background: #FFCF40;
padding-top: 25px;
}
/* Calculator Table Styles */
table#calculator {
background-color: rgb(211, 211, 211);
border: 10px outset rgb(92, 92, 92);
-moz-border-radius: 25px;
-webkit-border-radius: 25px;
border-radius: 25px;
padding: 15px;
margin: 0px auto;
-moz-box-shadow: rgb(101, 101, 101) 20px 10px 20px;
-webkit-box-shadow: rgb(101, 101, 101) 20px 10px 20px;
box-shadow: rgb(101, 101, 101) 20px 10px 20px;
}
table#calculator td {
width: 40px;
height: 40px;
margin: 10px;
}
table#calculator input {
-moz-border-radius: 7px;
-webkit-border-radius: 7px;
border-radius: 7px;
width: 100%;
height: 100%;
}
table#calculator textarea {
width: 100%;
height: 100px;
background-color: rgb(55, 105, 62);
font-size: 1.4em;
color: rgba(255, 255, 255, 0.7);
}
table#calculator td#decimalTD {
font-size: 0.9em;
text-align: right;
}
table#calculator input#decimals {
width: 35px;
height: 20px;
background: transparent;
text-align: center;
}
<article>
<table id="calculator">
<tr>
<td colspan="5">
<textarea id="calcWindow" name="calcWindow"></textarea>
</td>
</tr>
<tr>
<td>
<input id="button7" type="button" class="calcButton" value="7" />
</td>
<td>
<input id="button8" type="button" class="calcButton" value="8" />
</td>
<td>
<input id="button9" type="button" class="calcButton" value="9" />
</td>
<td>
<input id="buttonDivide" type="button" class="calcButton" value="/" />
</td>
<td>
<input id="buttonClear" type="button" class="calcButton" value="C" />
</td>
</tr>
<tr>
<td>
<input id="button4" type="button" class="calcButton" value="4" />
</td>
<td>
<input id="button5" type="button" class="calcButton" value="5" />
</td>
<td>
<input id="button6" type="button" class="calcButton" value="6" />
</td>
<td>
<input id="buttonMultiply" type="button" class="calcButton" value="*" />
</td>
<td rowspan="3">
<input id="buttonEnter" type="button" class="calcButton" value="enter" />
</td>
</tr>
<tr>
<td>
<input id="button1" type="button" class="calcButton" value="1" />
</td>
<td>
<input id="button2" type="button" class="calcButton" value="2" />
</td>
<td>
<input id="button3" type="button" class="calcButton" value="3" />
</td>
<td>
<input id="buttonMinus" type="button" class="calcButton" value="-" />
</td>
</tr>
<tr>
<td colspan="2">
<input id="button0" type="button" class="calcButton" value="0" />
</td>
<td>
<input id="buttonDecimal" type="button" class="calcButton" value="." />
</td>
<td>
<input id="buttonAdd" type="button" class="calcButton" value="+" />
</td>
</tr>
</table>
2
Answers
I know here it’s not a code free website but I found the idea interesting to see how it can be done with a grid.
As several comments is saying, it would be the right way to do that instead of table.
I made a snippet, it’s one possibility several different could be done.
For grid, using repeat 5 for row and col, and using span keyword on 0 on x axis and enter on y axis
also I put data attribute for each, you can read directly dataset of ekement cliked.
The problem is in the CSS, not the table. The 4/5/6/ row is aligning to the bottom of the Enter button and is therefore covered by the 0/./+ buttons.
Under your reset rules code, change this:
to this:
and it’ll work.