2

First off all, I've searched on StackOverflow, but I couldn't find a solution which fully works for me.

I have a div element and in there I have 2 other div elements that needs to be positioned next to each other.

The first div has a fixed with, while the second div should take the remaining screen space.

Thanks to StackOverflow already, I've found the following:

.element {
    margin-bottom:15px;
    height: 40px;
}
.element div {
    vertical-align: top;
    height: 40px;
}
.element div:first-child {
    float: left;
    width: 100px;
    background-color: red;
}
.element div:last-child {
    margin-left: 100px;
    background-color: green;
}
<div class="container">
    <div class="element">
        <div>col 1</div>
        <div>col 2</div>
    </div>
</div>

This gives me the following output for the HTML:

enter image description here

However, when I place an input element in the "col2", the input element is pushed outside the boundaries, see image below:

enter image description here

It's driving me nuts that I don't find a solution here.

I've creates a JsFiddle also.

GreyRoofPigeon
  • 17,833
  • 4
  • 36
  • 59
Complexity
  • 5,682
  • 6
  • 41
  • 84
  • http://stackoverflow.com/questions/1633522/html-input-element-wider-than-containing-div –  Aug 25 '14 at 10:30

3 Answers3

1

You can set the css box-sizing to border-box for removing padding that is added to width:

box-sizing : border-box;

Working Demo

Milind Anantwar
  • 81,290
  • 25
  • 94
  • 125
1

Set box-sizing: border-box; to .element INPUT - DEMO

.element INPUT {
    -webkit-box-sizing : border-box;‌
    -moz-box-sizing : border-box;
    box-sizing:border-box;
}
Anonymous
  • 10,002
  • 3
  • 23
  • 39
1

In order to make it work in all browsers, Change your css to this :

.element INPUT {width: 100%; box-sizing: border-box;
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;}
Jayant
  • 114
  • 3
  • 8