code_junkie

CSS: Textbox to Fill Parent Container

Nov 10th, 2011
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.45 KB | None | 0 0
  1. <!DOCTYPE html
  2. PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  3. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
  4. >
  5. <html>
  6. <head xmlns="http://www.w3.org/1999/xhtml">
  7. <title>Test</title>
  8. <style type="text/css">
  9. #x {
  10. background: salmon;
  11. padding: 1em;
  12. }
  13.  
  14. #y {
  15. background: red;
  16. padding: 0 20px;
  17. width: 100%;
  18. }
  19.  
  20. input {
  21. background: red;
  22. padding: 0 20px;
  23. width: 100%;
  24. }
  25. </style>
  26. </head>
  27. <body>
  28. <div id="x">
  29. <div id="y">x</div>
  30. <input type="text"/>
  31. </div>
  32. </body>
  33. </html>
  34.  
  35. input[type="text"] {
  36. -webkit-box-sizing: border-box; /* Safari/Chrome, other WebKit */
  37. -moz-box-sizing: border-box; /* Firefox, other Gecko */
  38. box-sizing: border-box; /* Opera/IE 8+ */
  39.  
  40. <div class="textbox" id="username">
  41. <div class="before"></div>
  42. <div class="during">
  43. <input type="text" value="" />
  44. </div>
  45. <div class="after"></div>
  46. </div>
  47.  
  48. margin: -1em;
  49.  
  50. input {
  51. background: red;
  52. padding: 0;
  53. width: 100%;
  54. border: 0; //use 0 instead of "none" for ie7
  55. }
  56.  
  57. .text-box {
  58. padding: 0 20px;
  59. border: solid 1px #000000;
  60. }
  61.  
  62. <body>
  63. <div id="x">
  64. <div id="y">x</div>
  65. <div class="text-box"><input type="text"/></div>
  66. </div>
  67. </body>
Add Comment
Please, Sign In to add comment