Reputation: 319
I have an input text field which is inside a div, I want to make it equal to the width of that div. I try to set the width same as the div by css, but when I resized the windows, the input field defected..
Upvotes: 1
Views: 9215
Reputation: 1361
You can set property of Div with
overflow:hidden
and set textbox with
width:100%
to avoid this issue. see this fiddle if helps http://jsfiddle.net/Rj8aj/
Upvotes: 0
Reputation: 2008
Demo Link with css
css
*{
padding:0;
margin:0;
}
body {
font:normal 12px/18px Arial, Helvetica, sans-serif;
color:#000;
padding:20px;
background-color:#F2F2F2;
}
ul, li, ol {
list-style-type:none;
}
.wrapper {
width:96%;
padding:2%;
margin:0 auto;
background-color:#3D3A40;
}
.greenBox {
background-color:#006600;
padding:50px;
}
.spacer {
clear:both;
font-size:0;
line-height:0;
height:0;
}
p {
padding-bottom:18px;
}
input {
height:26px;
border: none;
color:#fff;
border:#83bbd9 1px solid;
width:100%;
font:normal 12px/26px Arial, Helvetica, sans-serif;
}
HTML
<div class="wrapper">
<div class="greenBox">
<form action="" method="post">
<input name="" type="text" />
</form>
</div>
</div>
Upvotes: 0
Reputation: 2364
If you have paddings, use http://css-tricks.com/box-sizing/
input{
width:100%;
padding: 5px;
border:1px solid black;
-webkit-box-sizing: border-box; /* Safari/Chrome, other WebKit */
-moz-box-sizing: border-box; /* Firefox, other Gecko */
box-sizing: border-box; /* Opera/IE 8+ */
}
Upvotes: 2
Reputation: 109
give input text width as 100%
<input type="text" style="width: 100%"/>
Upvotes: 0