What is the recommended practice for using .col-*
as children in a .d-flex
container? Should .d-flex
be used with .row
instead?
I have noticed that the Bootstrap 4 Docs do not show any examples of using a .col-*
in a .d-flex
container. The layouts provided are like this:
<div class="d-flex flex-row">
<div class="p-2">Flex item 1</div>
<div class="p-2">Flex item 2</div>
<div class="p-2">Flex item 3</div>
</div>
<div class="d-flex flex-row-reverse">
<div class="p-2">Flex item 1</div>
<div class="p-2">Flex item 2</div>
<div class="p-2">Flex item 3</div>
</div>
However, the .p-2
classes in these examples do not make the columns responsive as they only define padding and do not specify width.
For example, I want something like this:
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/js/bootstrap.min.js"></script>
<div class="d-flex flex-wrap">
<div class="col-sm-3 col-12">
Responsive cols
</div>
<div class="col-sm-3 col-12">
Responsive cols
</div>
<div class="col-sm-3 col-12">
Responsive cols
</div>
<div class="col-sm-3 col-12">
Responsive cols
</div>
</div>
Is it considered good or bad practice according to Bootstrap guidelines to use .d-flex
and .col-*
together?