JSFiddle - React, Tailwind, and code Playground
by tjlahr
HTML
<form action="#">
<input type="text" placeholder="Enter text..."/>
<button type="submit">Submit</button>
</form>
CSS
/* Remove button margins in Webkit */
* { margin: 0; padding: 0; }
/* Remove button padding in FF */
button::-moz-focus-inner {
border:0;
padding:0;
}
/* push down form below "Result" label for demo */
body { margin-top: 50px; }
form {
/* style */
background-color: #333;
padding: 10px;
font-size: 20px;
}
form input {
/* style */
border: none;
padding: 7px;
/* default input size isn't wide enough */
width: 100%;
/* keeps input from overflowing its container */
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
/* prevents input from flowing behind the button */
padding-right: 60px;
/* line-height (which determines height) renders slightly different across browsers.
But specifiying a fixed line-height: 14px caused a 1px difference in IE.
I found it easier just to lock in the height */
height: 28px;
}
form button {
/* style */
background-color: lightblue;
border: none;
padding: 7px;
/* to match input height above */
height: 28px;
/* removes the box from DOM */
float: right;
/* alternative to negative margin-top,
which seems to hide my button behind the input */
position: relative;
top: -28px;
}