Answered
Bootstrap 5 and centering col-8
Hi,
If col-12 is changed to col-8, the content block is shifting to the left, even though the content within is centered. I would like this content block to maintain its appearance at the "col-8" width, but to be centered on the web page.
Not sure how I can do that? These are the opening tags found in this set-up.
<div class="container">
<div class="row">
<div class="col-8">
<div class="carousel slide carousel-fade" id="carouseCta" data-bs-ride="carousel">
<div class="carousel-inner">
<div class="carousel-item active" data-bs-interval="10000">
<div class="row h-100 align-items-center g-2">
<div class="col-12">
<div class="text-light text-center py-2">
...I suspect it may be something to do with the row, as in the code inspector I can see this style encompasses the extra gap to the container, causing the content to pull to the right:
.row {
--bs-gutter-x: 2rem;
--bs-gutter-y: 0;
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-ms-flex-wrap: wrap;
flex-wrap: wrap;
margin-top: calc(var(--bs-gutter-y) * -1);
margin-right: calc(var(--bs-gutter-x) / -2);
margin-left: calc(var(--bs-gutter-x) / -2);
}
--bs-gutter-x: 2rem;
--bs-gutter-y: 0;
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-ms-flex-wrap: wrap;
flex-wrap: wrap;
margin-top: calc(var(--bs-gutter-y) * -1);
margin-right: calc(var(--bs-gutter-x) / -2);
margin-left: calc(var(--bs-gutter-x) / -2);
}
