Reputation: 5355
I have an input element and I want it to take up the full size of the parent DIV. How do I achieve this? I tried width 100%
, yet it doesn't work. The problem I am facing is that the Parent has a blue background and the child has a yellow background. As a result, I can see some blue outline around the edges. How do I get rid of that.
I have a added a class for the child element. Something like this:
.input-editable { background-color: some-color; width: 100%; }
This element is wrapped in a div. That DIV has its background-color set that is visible on the edges. I don't want that to happen.
Thanks in advance!
Upvotes: 1
Views: 2493
Reputation: 1557
I think what you're looking for is
display: block;
width: 100%;
That will make your input element span the whole width of the parent.
Note that if you have padding on your input element, you better use this as well:
box-sizing: border-box;
Upvotes: 0
Reputation: 2904
Try the following code: (http://jsfiddle.net/MUDey/)
<!doctype html>
<html>
<head>
<style>
*{padding:0;margin:0;}
#parent { width: 75%; height: auto; background-color: Blue; }
.input-editable {
width: 100%;
height: auto;
}
</style>
</head>
<body>
<div id="parent">
<input type="text" class="input-editable" value="Show us your HTML" />
</div>
</body>
</html>
And please, post your HTML.
Upvotes: 0
Reputation: 47667
Just make your input
a block element and it will work - DEMO
.div input {
display: block;
width: 100%;
border: 0;
}
Upvotes: 1