css - How does padding + line-height overwrite height?
问题描述
in this example
https://codepen.io/team/css-tricks/pen/1ea1ef35d942d0041b0467b4d39888d3
When I played with padding
in .flex-item
css, I found it can overwrite height
limit that is padding + line-height > height
, where can I find such precedence?
解决方案
The total height of the element includes padding. You can add
box-sizing: border-box;
for .flex-item
border-box
tells the browser to account for any border and padding in the values you specify for an element's width and height. If you set an element's width to 100 pixels, that 100 pixels will include any border or padding you added, and the content box will shrink to absorb that extra width. This typically makes it much easier to size elements.
See https://developer.mozilla.org/en-US/docs/Web/CSS/box-sizing. for more details.
推荐阅读
- javascript - 如何忽略 HTML 表单中的禁用问题,以便我能够使用 HTML/JS 应用程序中的“下一步”按钮进入下一部分?
- reactjs - 为什么我的 fetch 请求在很短的时间内给了我很多错误
- r - R函数找不到作为参数提供的对象
- vue.js - 在模板部分的标签中有一个 vue 变量
- python - 将 matplotlib.collections.LineCollection 对象打印为文本(到字符串)
- swift - 在闭包中使用通用参数
- python - 为什么我的 python 返回值包含以前的打印文本?
- python - 将y轴的整数转换为日期
- python - 为什么我在循环中运行一个简单的函数时会出现类型错误?
- python - 打开 exe 文件时 subprocess.run 抛出未找到错误 heroku