Solved

make same size of textbox and TD

Posted on 2011-09-15
7
336 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
  • 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

This article describes how to create custom column layout styles for Bootstrap. The article uses 5 columns to illustrate the concept, but the principle can be extended to any number of columns.
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
In this tutorial viewers will learn how to style different bullet points for unordered lists in CSS. Begin with a normal unordered list; the default bullet point is a solid circle: In the CSS, create a defined class of unordered list by typing "ul.S…
In this tutorial viewers will learn how to embed Flash content in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <object> tag to embed Flash content.: To specify that the object is Flash content, d…

910 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now