Reputation: 469
My code for producing a plotly graphic within a boostrap card is below. I'm wondering the best way to ensure it is centered within the card on any device.
<div class="col-sm-6">
<div class="card bg-light text-white">
<div class="card-header bg-dark">
<center>A Plot</center>
</div>
<div class="card-body align-items-center" style="height: 20rem;">
<div class="chart" id="some_graph">
<script>
var graphs = {{some_plot | safe}};
Plotly.plot('some_graph', graphs, {});
</script>
</div>
</div>
</div>
</div>
Thank you for any suggestions
Upvotes: 1
Views: 1050
Reputation: 21506
card-body
is not displayed as flex box by default. If you want to use align-items-center
or even justify-content-center
, you need to enable the flex behaviors first:
<div class="card-body d-flex align-items-center justify-content-center">
...
</div>
The default direction of d-flex
is row so if you want the graphic to be:
justify-content-center
align-items-center
Upvotes: 1