Solved

make same size of textbox and TD

Posted on 2011-09-15
7
342 Views
Last Modified: 2012-05-12
Id liek the textbox size same as the width and height  of teh TD. How is taht done in HTML or CSS?
0
Comment
Question by:zachvaldez
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
7 Comments
 
LVL 38

Expert Comment

by:Tom Beck
ID: 36543394
<td style="width:300px;height:75px"><input type="text" style="width:100%;height:100%" /></td>

The textbox will fill the 300 x 75 pixel TD, textbox borders will overflow however.
0
 
LVL 38

Expert Comment

by:Tom Beck
ID: 36543501
Does not work in IE8 Compatibility mode.
0
 
LVL 38

Expert Comment

by:Tom Beck
ID: 36543714
As a workaround for IE8 Compatibility mode, you could use a little javascript to adjust the textbox or textarea height to match the height of the td. The width is not a problem except for the overflowing border which you can fix by making the width 98% instead of 100. For example:

<style type="text/css">
#txtBox {width:98%; height:100%}
#txtBox1 {width:98%; height:100%; overflow:hidden}
</style>

<td id="txtTd" style="width:300px;height:75px"><input type="text" id="txtBox" /></td>
 <td id="txtTd1" style="width:300px;height:75px"><textarea id="txtBox1"></textarea></td>

<script type="text/javascript" language="javascript">
document.getElementById('txtBox').style.height = document.getElementById('txtTd').style.height;
document.getElementById('txtBox1').style.height = document.getElementById('txtTd1').style.height;
</script>
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 25

Expert Comment

by:Kyle Hamilton
ID: 36546428
You could always add box-sizing:border-box; for the input style. IE's box model does this automatically. This way you get your borders inside the box in all other browsers - no need for percentages.

0
 

Author Comment

by:zachvaldez
ID: 36546523
Maybe I'm bothered with the borders of the textbox.can u add a css that when a textbox or label are use the borders would Nott that obvious .It doesn't look good with the td background space inside a table cell.
0
 
LVL 25

Expert Comment

by:Kyle Hamilton
ID: 36546601
I'm not sure I understand the concern.

Can you also post a link to your page? And a screenshot of what you would like it to look like...
0
 
LVL 38

Accepted Solution

by:
Tom Beck earned 200 total points
ID: 36547042
You can style the borders on the textboxes however you like:

Wide gray border:

#txtBox {width:98%; height:100%; border:solid 3px #ddd}
#txtBox1 {width:98%; height:100%; overflow:hidden; border:solid 3px #ddd}

No border:

#txtBox {width:98%; height:100%; border:0}
#txtBox1 {width:98%; height:100%; overflow:hidden; border:0}

You could also play with the borders on the TDs.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Not sure what the best email signature size is? Are you worried about email signature image size? Follow this best practice guide.
This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
In this tutorial viewers will learn how to style rounded corners for elements in CSS using the border-radius property Begin with a normal styled element such as a div: To style all four corners of the div to be the same degree of roundness, use the …
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question