When using flexbox for styling, if the parent container is set to display: flex
it will cause the <hr />
to be displayed vertically instead of horizontally.
.container {
display: flex;
flex: 1;
}
<div class='container'>
<h2>Test</h2>
<hr />
</div>
Use
flex-grow: 1
orwidth: 100%
so it will grow to match the width of the parent. You probably want to use that in combination withflex-wrap: wrap
on.container
if you plan on putting more flex children in.container
The reason for this is that default value of
align-items
isstretch
sohr
will get the same height as largest element inflex-container
or in this caseh2
. And default value forjustify-content
isflex-start
so width ofhr
is 0.Easy way to fix this is to use
flex-wrap: wrap
on parent element andflex: 0 0 100%
onhr