Bootstrap responsive container

bootstrap question
<section class="c-blog container">
<div class="row">
<div class="col-12 col-lg-6">
<div class="c-blog__info">
<div class="c-blog__title">
<p>{{ time.timeAgo(section.postDate) }}</p>
{% set title = section.title ?? '' %}
{% set parts = title|split('#')|filter(v => v|trim is not empty) %}

{% include '_components/_subtitle.twig' with {
title: parts[0] ?? '',
description: parts[1] ?? ''
} %}
</div>

<div class="c-blog__description">
<p>{{ section.description }}</p>
<a href="{{ section.blogLink.value }}">{{ section.blogLink.label }}</a>
</div>
</div>
</div>

<div class="col-12 col-lg-6">
{{ img.responsiveImage(photo, {
aspectRatio: '100:100',
quality: 80,
transformHandle: 'img2Webp'
}) }}
</div>
</div>
</section>
<section class="c-blog container">
<div class="row">
<div class="col-12 col-lg-6">
<div class="c-blog__info">
<div class="c-blog__title">
<p>{{ time.timeAgo(section.postDate) }}</p>
{% set title = section.title ?? '' %}
{% set parts = title|split('#')|filter(v => v|trim is not empty) %}

{% include '_components/_subtitle.twig' with {
title: parts[0] ?? '',
description: parts[1] ?? ''
} %}
</div>

<div class="c-blog__description">
<p>{{ section.description }}</p>
<a href="{{ section.blogLink.value }}">{{ section.blogLink.label }}</a>
</div>
</div>
</div>

<div class="col-12 col-lg-6">
{{ img.responsiveImage(photo, {
aspectRatio: '100:100',
quality: 80,
transformHandle: 'img2Webp'
}) }}
</div>
</div>
</section>
I currently have my container set up like this but does anyone know a way using bootstrap how to make sure the image does take the full fluid width? as shown in the image
No description
62 Replies
ἔρως
ἔρως4w ago
what do you want the image to do?
Kingpin
KingpinOP4w ago
atm the image takes the size of the container, but I want the width to stretch out to the viewport edge.
No description
Kingpin
KingpinOP4w ago
like this from the design
No description
Kingpin
KingpinOP4w ago
I already had a solution but the text doesn't align with the other text on the page which uses the bootstrap containers
ἔρως
ἔρως4w ago
basically, you want the image to leave the container?
Kingpin
KingpinOP4w ago
ye, havent really found a class for that. I mean you have container-fluid but it doesnt'seem to work as expected when I put it on the div where the col classes are
ἔρως
ἔρως4w ago
i honestly forgot how it used to be done, but was a massive pita
Mannix
Mannix4w ago
i don't think there is one for that on bootstrap
Kingpin
KingpinOP4w ago
ye...
ἔρως
ἔρως4w ago
no, but there are tricks to make it happen
Kingpin
KingpinOP4w ago
How do you even call this? cuz idk what to look for..
ἔρως
ἔρως4w ago
escape the container but i have an idea for you this is pseudo-code:
<row - width 100dvw and 0 padding>
<col-6 margin-left equal to .container>
content comes here
<col-6>
image comes here
<row - width 100dvw and 0 padding>
<col-6 margin-left equal to .container>
content comes here
<col-6>
image comes here
Kingpin
KingpinOP4w ago
picture {
display: block;
width: 50vw;

img {
width: 100%;
height: $height;
object-fit: cover;
}
}
picture {
display: block;
width: 50vw;

img {
width: 100%;
height: $height;
object-fit: cover;
}
}
I fixed it lol apparently it was as simple as adding display block and width 50vw uh not quite nvm lol
Kingpin
KingpinOP4w ago
it works here
No description
ἔρως
ἔρως4w ago
you should set an aspect ratio the image is stretched
Kingpin
KingpinOP4w ago
but not here
No description
Kingpin
KingpinOP4w ago
the aspect ratio is already set in twig tho?
{{ img.responsiveImage(photo, {
aspectRatio: '1:1',
quality: 80,
transformHandle: 'img2Webp'
}) }}
{{ img.responsiveImage(photo, {
aspectRatio: '1:1',
quality: 80,
transformHandle: 'img2Webp'
}) }}
ἔρως
ἔρως4w ago
is it set in css?
Kingpin
KingpinOP4w ago
it doesn't change anything if I add it in css. the images don't look stretched tho
ἔρως
ἔρως4w ago
if you remove the height, it will
Kingpin
KingpinOP4w ago
no?
No description
Kingpin
KingpinOP4w ago
the object-fit: cover was already there
ἔρως
ἔρως4w ago
you're setting the wrong aspect ratio that can't be 1:1
Kingpin
KingpinOP4w ago
idk what you're talking about tho, I get it from the aspect ratio but not the stretched image.
ἔρως
ἔρως4w ago
if you hover the url, what does it say?
Kingpin
KingpinOP4w ago
No description
Kingpin
KingpinOP4w ago
the rendered size is different the the actual size, I think this is the case with all my images.
ἔρως
ἔρως4w ago
you should set an aspect-ratio: 1/1
vince
vince4w ago
Could not use bootstrap for this section and then just use grid. My 2cents
Kingpin
KingpinOP3w ago
I found a fix on Stackoverflow actually. He did some calculations with left and right using position relative.
position: relative;
right: calc(-1 * (100vw - 200%) / 2);
left: 0;
position: relative;
right: calc(-1 * (100vw - 200%) / 2);
left: 0;
For those curious this is what they did. it respect the bootsrap container but visually it will appear the way I want.
ἔρως
ἔρως3w ago
use margins instead
Kingpin
KingpinOP3w ago
if you want it for the other side then do the same for left as you did with right and set right to 0
ἔρως
ἔρως3w ago
position relative can mess with position absolute elements
Kingpin
KingpinOP3w ago
nah it works I leave it at that.
ἔρως
ἔρως3w ago
margin works too
Kingpin
KingpinOP3w ago
my sections are seperate from each other and this section doesn't use any position absolutes
ἔρως
ἔρως3w ago
same exact code, except it's margin-left
Kingpin
KingpinOP3w ago
if the switch is that easy I will try it.
ἔρως
ἔρως3w ago
you don't need to specify anything else it is remove the position and the right rename left to margin-left
Kingpin
KingpinOP3w ago
okay I changed it to that thx
ἔρως
ἔρως3w ago
you're welcome
Kingpin
KingpinOP3w ago
really wish that bootstrap had a class to break out the container to do stuff like this
ἔρως
ἔρως3w ago
yeah, but it isn't made for that
Kingpin
KingpinOP3w ago
container-break or something
ἔρως
ἔρως3w ago
but would be nice
Kingpin
KingpinOP3w ago
fuck, I just noticed the images on the right causes an overflow I did a overfow-x: hidden on the body if there are other solutions they're welcome
ἔρως
ἔρως3w ago
use 100dvw instead of 200%
Kingpin
KingpinOP3w ago
is dvw supported baseline? wait uh, the overflow only happens when I am not in inspector mode
ἔρως
ἔρως3w ago
you can do this: (100dvw - <size you want>) / 2
Kingpin
KingpinOP3w ago
that just breaks the styles
ἔρως
ἔρως3w ago
do this i saw it in other places the <size you want> is the width of the container
Kingpin
KingpinOP3w ago
margin-right: calc(-1 * (100dvw - 100dvw) / 2);
margin-right: calc(-1 * (100dvw - 100dvw) / 2);
I am doing this on my even section blogs, but there is still a overflow
ἔρως
ἔρως3w ago
you're doing 0 / 2 -1 * 0 / 2 is 0 / 2 which is ...
Kingpin
KingpinOP3w ago
even if I change the second dvw to another value it still hits me with the overflow
ἔρως
ἔρως3w ago
did you remove the 8px margin in the body?
Kingpin
KingpinOP3w ago
wdym?
ἔρως
ἔρως3w ago
by default, the body has 8px of margin or padding or whatever
Kingpin
KingpinOP3w ago
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
I have this?
ἔρως
ἔρως3w ago
ew but yeah, that work i have a visceral reaction to that reset
Kingpin
KingpinOP3w ago
why?
ἔρως
ἔρως3w ago
because it serves no purpose you remove all the margins and paddings, to then add them all back usually, to the exact same values you just removed
Kingpin
KingpinOP3w ago
when I remove the box-sizing nothing changes tho

Did you find this page helpful?