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

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

    Here is the recommendation from codeontrack.com, which has good solution examples:

    Instead of setting the width of the div to 100%, set it to auto, and be sure, that the

    is set to display: block (default for
    ).

提交回复
热议问题