diff --git a/index.html b/index.html index fa202df..91a49e1 100644 --- a/index.html +++ b/index.html @@ -8,7 +8,7 @@ - + @@ -22,11 +22,13 @@

Labels inside form fields

-

This is one of the best ways to place labels inside input fields, like so:

+

This is one of the best ways to place labels inside input fields, like so: + +

The solution is based on simple HTML markup, some CSS, and a jQuery plugin. The license is MIT.

@@ -39,32 +41,32 @@

Labels inside form fields

Demo

diff --git a/labels.css b/labels.css index 46be352..8b13789 100644 --- a/labels.css +++ b/labels.css @@ -1,28 +1 @@ -.input { - display: block; -} -.input span { - position: absolute; - z-index: 1; - cursor: text; - pointer-events: none; - color: #999; - /* Input padding + input border */ - padding: 7px; - /* Firefox does not respond well to different line heights. Use padding instead. */ - line-height: 17px; - /* This gives a little gap between the cursor and the label */ - margin-left: 2px; -} -.input input, .input textarea, .input select { - z-index: 0; - padding: 6px; - margin: 0; - font: inherit; - line-height: 17px; -} -.input select { - padding: 5px; - /* Unfortunately selects don't respond well to padding. They need an explicit height. */ - height: 31px; -} + diff --git a/site/site.css b/site/site.css index 171b435..87bd267 100644 --- a/site/site.css +++ b/site/site.css @@ -37,3 +37,16 @@ input, textarea, select { min-width: 300px; box-sizing: border-box; } +input { + height: 2rem; +} + +label { + font-weight: bold; + font-size: 1.2rem; + display: flex; + align-items: start; + justify-content: center; + flex-direction: column; + padding: 12px 6px; +}