888 B
888 B
title, tags, firstSeen, lastUpdated
| title | tags | firstSeen | lastUpdated |
|---|---|---|---|
| Box-sizing reset | layout,beginner | 2018-02-27T18:59:09+02:00 | 2020-12-30T15:37:37+02:00 |
Resets the box-model so that width and height are not affected by border or padding.
- Use
box-sizing: border-boxto include the width and height ofpaddingandborderwhen calculating the element'swidthandheight. - Use
box-sizing: inheritto pass down thebox-sizingproperty from parent to child elements.
<div class="box">border-box</div>
<div class="box content-box">content-box</div>
div {
box-sizing: border-box;
}
*,
*:before,
*:after {
box-sizing: inherit;
}
.box {
display: inline-block;
width: 120px;
height: 120px;
padding: 8px;
margin: 8px;
background: #F24333;
color: white;
border: 1px solid #BA1B1D;
border-radius: 4px;
}
.content-box {
box-sizing: content-box;
}