Setup
.container {
position: relative;
display: flex;
flex-direction: row;
justify-content: flex-start;
flex: 1 1;
padding: 28px;
width: 100%;
background-color: #eee;
}
.bar {
position: relative;
width: 5px;
background-color: blue;
}
<div class="container">
<div class="bar"></div>
<div>
lskdjf
</div>
</div>
Notice that the blue bar reaches the full height of the container, minus the padding.
If I add height: 100%
to the .bar
class however, the height disappears.
.bar {
position: relative;
width: 5px;
background-color: blue;
height: 100%;
}
Question
I imagine that actually setting height to 100% confuses the browser because the parent doesn't actually have a height that is set, but what property pre-setting-height-to-100% allows the height to then be 100%? And, given that this is actually my goal, would it be "correct" to just not specify 100%, or is there a better way to ensure the .bar
element reaches the full height?