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

前端 未结 14 1489
庸人自扰
庸人自扰 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:17

    Assuming i'm in a container with 15px padding, this is what i always use for the inner part:

    width:auto;
    right:15px;
    left:15px;
    

    That will stretch the inner part to whatever width it should be less the 15px either side.

提交回复
热议问题