Div with margin-left and width:100% overflowing on the right side

后端 未结 6 466
太阳男子
太阳男子 2021-02-04 02:28

I have 2 nested div\'s that should be 100% wide. Unfortunately the inner div with the Textbox overflows and is actually larger than the outer div. It has a left margin and overf

6条回答
  •  无人共我
    2021-02-04 03:07

    I realise this is an old post but this might benefit somebody who, like me, has come to this page from a google search and is at their wits end.

    None of the other answers given here worked for me and I had already given up hope, but today I was searching for a solution to another similar problem with divs, which I found answered multiple times on SO. The accepted answer worked for my div, and I had the sudden notion to try it for my previous textbox issue - and it worked! The solution:

    add box-sizing: border-box to the style of the textbox.

    To add this to all multi-line textboxes using CSS, add the following to your style sheet:

    textarea
    {
      box-sizing: border-box;
    }
    

    Thanks to thirtydot for the solution at

    width: 100%-padding?

    and

    Content of div is longer then div itself when width is set to 100%?

提交回复
热议问题