Solved

make same size of textbox and TD

Posted on 2011-09-15
7
335 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
Comment Utility
<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
Comment Utility
Does not work in IE8 Compatibility mode.
0
 
LVL 38

Expert Comment

by:Tom Beck
Comment Utility
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
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 
LVL 25

Expert Comment

by:Kyle Hamilton
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Suggestion on WebSite Template Sites 5 50
Drop down button NAMES disappear 1 37
HTML page and JavaScript 2 49
modify h2 4 8
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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 transparent/translucent elements using alpha transparency in CSS Start with a normal styled element, such as a div.: Define its "background-color" property as "rgba (255, 255, 255, .5): The numbers in…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

743 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

18 Experts available now in Live!

Get 1:1 Help Now