100% WIDTH TEXT AREA WITH ADJACENT BUTTON


/ Published in: HTML
Save to your folder(s)

A contract I work on uses tables to layout forms (kinda ghetto I know) and I wanted a text field with a button text to it that would work with their 100% width scheme. Normall it places to betton below the text input, but using this HTML and CSS it will go next to it.

One thing to note is that the button has to have a width, and you need that width + any margin you give the button to be updated accordingly. In this example the button is 95P with a 5Px right margin on it, the to magic number is 100Px, it has to be updated in both the inline style on the table and in he CSS. Also this will work outside a table, as long as all the divs are in something with an appropriate badding on it.

There is no reason that can't all be inline or all be in the stylesheet, it's just based on the way they lay out the becked of their CMS.

Questions can be posted here or (preferable) at the link, theres an example of it in action there too (not that it's a complicated thing to make yourself)


Copy this code and paste it in your HTML
  1. <!-- CSS First (Obviously this needs to be places in a style tag in the head)
  2. div.input_master{
  3. width:100%;
  4. display:inline-block;
  5. white-space: nowrap;
  6. }
  7. div.input_subset{
  8. display:inline;
  9. width:100%;
  10. }
  11. input.text{
  12. width:100%;
  13. }
  14. input.button{
  15. width:90px;
  16. margin-right:5px;
  17. display:inline;
  18. }
  19. End CSS -->
  20.  
  21. <!-- HTML code -->
  22. <table border="1" width="100%">
  23. <tr>
  24. <td style="width:15%;">Enter Text</td>
  25. <td style="width:35%;padding-right:100px;">
  26. <div class="input_master">
  27. <div class="input_subset">
  28. <input type="text" class="text" />
  29. </div>
  30. <input type="button" class="button" value="Button">
  31. </div>
  32. </td>
  33. <td style="width:15%;"></td>
  34. <td style="width:35%;"></td>
  35. </tr>

URL: http://fatfolderdesign.com/225/css/100-width-text-area-with-adjacent-button

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.