I have a flex container with a couple of children that I need to have a before element on. The before element displays if the parent container is display: block
but not if it's display: flex
! is there a workaround for this?
:before doesn't work, but child container styling is fine:
<div class="parent">
<div></div>
<div></div>
</div>
<style lang="scss">
.parent {
display: flex;
justify-content: space-between;
position: relative;
&:before {
content: '';
position: absolute;
top: -20px;
height: 20px;
width: 100%;
background: linear-gradient(180deg, transparent, $gray);
}
}
</style>
:before works, but breaks my child element styling:
<div class="parent">
<div></div>
<div></div>
</div>
<style lang="scss">
.parent {
display: block;
position: relative;
&:before {
content: '';
position: absolute;
top: -20px;
height: 20px;
width: 100%;
background: linear-gradient(180deg, transparent, $gray);
}
}
</style>
margin-right:auto;
for the first div element, whether it solved the problem?