JSFiddle - React, Tailwind, and code Playground
HTML
<h1>Please complete the form below</h1>
<table width="100%">
<col />
<col width="150"/>
<tr>
<td><a title="Some additional help text will appear here">?</a>
This is a simple question.</td>
<td><div><input type="number" value="1" ></div></td>
</tr>
<tr>
<td><a title="Some additional help text will appear here">?</a>
This is a very long <br/> question spanning <br/> multiple lines.</td>
<td><div><input type="date" value="2000-01-01"></div></td>
</tr>
<tr>
<td><a title="Some additional help text will appear here">?</a>
This is a very long <br/> question spanning <br/> multiple lines.</td>
<td><div><textarea>Multi-line
answer</textarea></div></td>
</tr>
<tr>
<td><a title="Some additional help text will appear here">?</a>
This is a yes/no question using radios</td>
<td><div>
<label>Yes:<input name="boolean1" type="radio" value="1"/></label>
<label>No:<input name="boolean1" type="radio" value="0"/></label>
</div></td>
</tr>
<tr>
<td><a title="Some additional help text will appear here">?</a>
This is a yes/no question using checkbox</td>
<td><div>
<label>Yes:<input name="boolean1" type="checkbox" value="1"/></label>
</div></td>
</tr>
</table>
<h1>Explanation</h1>
<ul>
<li>This is an example of a data capture form where it can be safely assumed that the client has an HTML 5 browser.</li>
<li>We chose to use TABLE elements because if its powerful layout logic. Specifically, the question text will be coming from a database which can be modified by an admin user, and thus not known at design time. It is therefore unwise to make any assumptions about the minimum or maximum height of each row, but whatever height is needed to display the question on the left, the input on the right should have the same height.</li>
<li>Because different operating systems put different border "chrome" on input boxes and text areas, pages rendered...
CSS
input:not([type=radio]):not([type=checkbox])
{
min-height: 20px; /* fix for Chrome on Mac bug */
overflow: hidden; /* fix for Chrom on PC bug */
}
*
{
font-family: "Arial";
font-size: 11pt;
font-weight: normal;
}
html, body
{
position: absolute;ďś«
width: auto; left:0; right: 0;
height: auto; top: 0; bottom: 0;
background: #cee;
padding: 10px;
}
h1
{
font-size: 20pt;
font-weight: bold;
margin: 20px 0 5px; 0;
}
table
{
border-collapse: collapse;
}
td
{
position: relative;
padding: 5px;
vertical-align: top;
/*border: 1px solid green;*/
height: 25px;
}
td
{
border-radius: 5px;
border-bottom: 1px solid silver;
border-top: 1px solid silver;
}
td a
{
float: right;
color: #800;
margin: 5px 0 0 5px;
}
td div
{
position: absolute;
width: auto; left:5px; right: 5px;
height: auto; top: 5px; bottom: 5px;
background: #fff;
border-radius: 5px;
box-shadow: inset 1px 1px 5px #888;
overflow: hidden;
vertical-align: middle;
line-height: 25px;
padding: 0 5px;
}
input:not([type=radio]):not([type=checkbox]),
textarea
{
position: absolute;
width: auto; left: 0; right: 2px;
height: auto; top: 2px; bottom: 2px;
color: black;
border: none;
display: block;
vertical-align: top;
padding: 0 5px;
background: none;
}
input[type=radio],
input[type=checkbox]
{
height: 20px;
vertical-align: bottom;
}
textarea
{
overflow-x: hidden;
overflow-y: auto;
resize: none;
}