How to make an element width: 100% minus padding?

前端 未结 14 1454
庸人自扰
庸人自扰 2020-11-21 07:33

I have an html input.

The input has padding: 5px 10px; I want it to be 100% of the parent div\'s width(which is fluid).

However using widt

14条回答
  •  逝去的感伤
    2020-11-21 08:08

    For me, using margin:15px;padding:10px 0 15px 23px;width:100%, the result was this:

    The solution for me was to use width:auto instead of width:100%. My new code was:

    margin:15px;padding:10px 0 15px 23px;width:auto. Then the element aligned properly:

提交回复
热议问题