Is there a more efficient method to align flex items in different div flex containers so that the flex items have the same width, as shown below?
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.4.1.slim.min.js" integrity="sha384-J6qa4849blE2+poT4WnyKhv5vZF5SrPo0iEjwBvKU7imGFAV0wwj1yYfoRSJoZ+n" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="86f6e9f6f6e3f4a8ecf5c6b7a8b7b0a8b6">[email protected]</a>/dist/umd/popper.min.js" integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js" integrity="sha384-wfSDF2E50Y2D1uUdj0O3uMBJnjuUD4Ih7YwaYd1iqfktj0Uod8GCExl3Og8ifwB6" crossorigin="anonymous"></script>
<div class="d-flex alert p-0 mb-2">
<div class="p-1 bg-primary" style="width: 130px">short</div>
<div class="p-1 bg-secondary" style="width: 110px">mediuuum</div>
<div class="p-1 bg-info" style="width: 80px">loooooong</div>
</div>
<div class="d-flex alert p-0 mb-2">
<div class="p-1 bg-primary" style="width: 130px">looooooooooong</div>
<div class="p-1 bg-secondary" style="width: 110px">short</div>
<div class="p-1 bg-info" style="width: 80px">mediuuum</div>
</div>
<div class="d-flex alert p-0 mb-2">
<div class="p-1 bg-primary" style="width: 130px">mediuuum</div>
<div class="p-1 bg-secondary" style="width: 110px">looooooooong</div>
<div class="p-1 bg-info" style="width: 80px">short</div>
</div>
notes:
- The flex divs need to be generated in a loop, with their widths determined at the end for horizontal alignment
- This example is simplified; actual flex items have varying lengths
This is how the flex items would look without custom width calculation:
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.4.1.slim.min.js" integrity="sha384-J6qa4849blE2+poT4WnyKhv5vZF5SrPo0iEjwBvKU7imGFAV0wwj1yYfoRSJoZ+n" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="6d1d021d1d081f43071e2d5c435c5b435d">[email protected]</a>/dist/umd/popper.min.js" integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js" integrity="sha384-wfSDF2E50Y2D1uUdj0O3uMBJnjuUD4Ih7YwaYd1iqfktj0Uod8GCExl3Og8ifwB6" crossorigin="anonymous"></script>
<div class="d-flex alert p-0 mb-2">
<div class="p-1 bg-primary">short</div>
<div class="p-1 bg-secondary">mediuuum</div>
<div class="p-1 bg-info">loooooong</div>
</div>
<div class="d-flex alert p-0 mb-2">
<div class="p-1 bg-primary">looooooooooong</div>
<div class="p-1 bg-secondary">short</div>
<div class="p-1 bg-info">mediuuum</div>
</div>
<div class="d-flex alert p-0 mb-2">
<div class="p-1 bg-primary">mediuuum</div>
<div class="p-1 bg-secondary">looooooooong</div>
<div class="p-1 bg-info">short</div>
</div>
Is there a built-in feature that handles this alignment without relying on manual width adjustments?