Form Styling

by Preston Badeer

HTML

<form>
    <input type="text" disabled="disabled" placeholder="small" class="sm" />
    <input type="text" disabled="disabled" placeholder="default" />
    <input type="text" disabled="disabled" placeholder="large" class="lg" />
     <h3>disabled</h3>

    <input type="text" disabled="disabled" value="small" class="sm" />
    <input type="text" disabled="disabled" value="default" />
    <input type="text" disabled="disabled" value="large" class="lg" />
     <h3>disabled with value</h3>

    <input type="search" placeholder="small" class="sm" />
    <input type="search" placeholder="default" />
    <input type="search" placeholder="large" class="lg" />
     <h3>search</h3>

    <input type="text" class="sm" placeholder="small" />
    <input type="text" placeholder="default" />
    <input type="text" class="lg" placeholder="large" />
     <h3>text</h3>

    <select class="sm">
        <option>small</option>
    </select>
    <select>
        <option>default</option>
    </select>
    <select class="lg">
        <option>large</option>
    </select>
     <h3>dropdown</h3>

    <input type="radio" class="sm" />
    <input type="radio" />
    <input type="radio" class="lg" />
     <h3>radio</h3>

    <input type="checkbox" class="sm" />
    <input type="checkbox" />
    <input type="checkbox" class="lg" />
     <h3>checkbox</h3>

    <label class="sm">small</label>
    <label>default</label>
    <label class="lg">large</label>
     <h3>label</h3>

    <textarea class="sm" placeholder="small"></textarea>
    <textarea placeholder="default"></textarea>
    <textarea class="lg" placeholder="large"></textarea>
     <h3>text area</h3>

    <select multiple="true" class="sm">
        <option>small</option>
        <option>small</option>
        <option>small</option>
        <option>small</option>
    </select>
    <select multiple="true">
        <option>default</option>
        <option>default</option>
        <option>default</option>
        <option>default</option>
   ...

CSS

/* ignore below */
 h3 {
    font-size: 1em;
    font-family: verdana, sans-serif;
    font-weight: normal;
    text-transform: capitalize;
    margin: 0 0 1em 0;
    padding: 0;
}
html, body {
    font-size: 12px;
}
/* ignore above */

/* Global Form Element Styles */
 input, textarea, select, button {
    border: 1px solid #999;
    outline: none;
    background: white;
    border-radius: 4px;
    padding: 0.3em 0.4em;
    color: #444;
}
/* Focus Glow */
 input:focus, textarea:focus, select:focus, button:focus {
    border: 1px solid #6495ed;
    box-shadow: 0 0 5px #6495ed;
}
/* Font Sizing */
 input, textarea, select, label, button {
    font-size: 1em;
}
input.sm, textarea.sm, select.sm, label.sm, button.sm {
    font-size: 0.8em;
}
input.lg, textarea.lg, select.lg, label.lg, button.lg {
    font-size: 1.5em;
}
/* Buttons */
 button {
    cursor: pointer;
    padding-left: 0.6em;
    padding-right: 0.6em;
}
button:hover, button:focus {
    background: #DDD;
}
/* Indiviual Form Elements */
 label {
    text-align: right;
    vertical-align: middle;
    line-height: 1em;
    margin: 0 0.3em 0 0;
}
select {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    text-indent: 0.01px;
    text-overflow:'';
    padding-right: 1.5em;
    background: url('downarrow') center right no-repeat;
}
input[disabled="disabled"] {
    background: #EEE;
    color: #777;
}
input[type="search"], input.search {
    border-radius: 1.1em;
    background: white;
}