JSFiddle - React, Tailwind, and code Playground
by lukas_li
HTML
default width of block level box
<div class="p">
parent
<div class="c b">children</div>
</div>
absolute box with no width
<div class="p">
parent
<div class="a b">children</div>
</div>
fixed box with no width
<div class="p">
parent
<div class="fi b">chilrend</div>
</div>
float box with no width
<div class="p">
parent
<div class="f b">children</div>
</div>
CSS
.p {
width: 300px;
height: 80px;
margin-top: 20px;
margin-bottom: 20px;
background-color: red;
}
.b {
/* width: 100%; */
height: 40px;
/* padding: 0 10px; */
background-color: black;
color: white;
}
.c {
/* width: 100%;*/
padding: 10px;
}
.a {
/* display: block; */
position: absolute;
}
.fi {
position: fixed;
}
.f {
float: right;
/* width: 100%; */
}