0

So the problem is that in my div around listbox(select) + textbox(input text) + button(input submit) I have width:250px for the whole div and for the each thing inside it I have width:100%.

That makes me assume that they should logically fill the space inside that div. But the problem is that the textbox(input text in the fiddle) is kinda longer(or the other elements are shorter?).

Any ideas why and how to solve this problem?

Demo: http://jsfiddle.net/xXVHu/15/

Update: Thanks for flagging this as duplicate but can you tell me where is the answer for the explaination of:

Why is that input - text wider but input - submit not?

Also I would like to say that I need it to work in IE8, don't ask me why...


In my whole code all the divs I have have some kind of meaning so if you feel like they are useless, they aren't!

Ms. Nobody
  • 1,219
  • 3
  • 14
  • 34

2 Answers2

4

you can add

box-sizing:border-box;

to #but, #text inside your css and it will work fine

#but, #text
{
    display:inline-block;   
    width: 100%; 
    box-sizing:border-box;
    -webkit-box-sizing: border-box; /* Safari/Chrome, other WebKit */
    -moz-box-sizing: border-box;
}

jsFiddle : http://jsfiddle.net/xXVHu/20/

Ahmed Alaa El-Din
  • 1,813
  • 1
  • 16
  • 19
1

Try to apply box-sizing. This property will take into account borders and padding when computing the length of the element. http://css-tricks.com/box-sizing/