I have the following small snippet:
.container {
display: flex;
justify-content: space-between;
.btn {
font-size: 12px;
}
}
<div class="container">
<h3>This heading wont always be here</h3>
<button class="btn">This button always will and should be on the right</button>
</div>
Basically its a header that will always contain the button (which should always be positioned on the right) and a heading (which is optional).
At times, a heading will not exist and therefore the button will sit on the left hand side, I know that updating the justify-content
property to flex-end
achieves the outcome I want (in the chrome inspector) but how can I update my CSS to make this check? Ie, if no <h3>
, then use justify-content: flex-end
instead of space-between
?
I tried using the not
selector like this but to no avail:
:not(h3) {
justify-content: flex-end;
}