Reputation: 149
so im trying to exactly center one flex(unless anyone has other idea) item and aligning second one e.g 20px to right of my first item. My code:
<div className="d-flex justify-content-center border">
<h1 className="title">Tacos</h1>
<div className="icon"></div>
</div>
As you can see, they both are centered, my goal is to put text "Tacos" in exact center and then align my icon like 20px to right. Is there a way to do it?
Upvotes: 1
Views: 128
Reputation: 27381
You can use width: 0; white-space: nowrap;
trick.
.flex {
display: flex;
justify-content: center;
}
.icon {
width: 0;
white-space: nowrap;
margin-left: 20px;
}
<div class="flex">
<div class="text">Tacos</div>
<div class="icon">🌮🌮🌮🌮🌮🌮🌮</div>
</div>
Upvotes: 3