Textareas with a 100% width and no overflow
After a poke-around in the Facebook source code a colleague of mine found this awesome little technique to get textareas with a width of 100% to behave exactly as you want them to.
If you just slam { width:100% } on the textarea you usually end up with a textarea that overflows its container. That since the textarea’s width will be 100% + padding + borders. You need to counter the padding and borders.
The absolute easiest way to do that is to add padding to the wrapping element.
- <!doctype html>
- <html lang="en">
- <head>
- <style>
- label { padding: 0; marign: 0; display: block; }
- textarea { width: 100%; border: 1px solid #333; padding: 4px; }
- .the-fix { padding-right: 10px; }
- </style>
- </head>
- <body>
- <label class="the-fix">
- A good-looking textarea with a 100% width
- <textarea></textarea>
- </label>
- </body>
- </html>
The width of the input is 100% of its container + 1px + 1px (borders) + 4px + 4px (padding). In other words the width is 100% + 10px; Therefore we give the fix class an extra 10px padding to the right.
3 days ago
Wow! I don’t even remember anymore how I managed before this new awesome boilerstrap. http://t.co/bWzwqVf2
3 days ago
If you like coding and competing and want to see Stockholm at its best; Checkout Escape from /dev/null – DICE edition. http://t.co/0SapzZxz
4 days ago
Last night @soe, @tussetor and I won #sthlmstartuphack and the best trophy ever. http://t.co/CJ15cNml
4 days ago
Thanks @kalasjocke, @martinaelm, @javve for a super fun event. Thanks @soe, @tussetor for being awesome teammates. #sthlmstartuphack
4 days ago
Going where none has gone before and pushing the boundaries of what has been called done. Mine, @soe, @tussetor #SthlmStartupHack app ≈Done
6 days ago
Selected map, data and chart tools. http://t.co/I7l6qq4O (via @VirUZI) So much joy in one single place!
7 days ago
How can Comic Sans make people buy your app? http://t.co/KYLGeIW2