image outside of a container section [duplicate] - css

This question already has answers here:
Bootstrap full-width with 2 different backgrounds (and 2 columns)
(2 answers)
Closed 2 years ago.
I have a little problem I can't solve myself.
The whole section is inside such container (need to keep it as I align elements vertically with elements from other sections.
I don't have any issue to display in the right position the image inside this container using Flexbox or grid but as you can see in the illustration I need the image always stick on the right but stay in the same position on the left. It's kind of absolute but when I ad absolute I have an issue with the section above. any ideas?
exemple of behaviour : https://www.bain.com/insights/how-to-give-feedback-on-agile-ideas/
<!-- Title & Category Section-->
<section class="container px-4 mx-auto mt-32">
<div class="grid grid-cols-12">
<div class="col-span-8 col-start-4">
<div class="mb-2 text-sm font-light">{{ range .Params.Categories }}
{{ . | humanize }}
{{ end }}
</div>
</div>
<div class="col-span-8 col-start-4">
<div class="mb-4 text-6xl font-bold"><h1>{{ .Title }}</h1></div>
</div>
<div class="col-span-7 col-start-4">
<div class="mb-10 text-2xl">{{ .Params.Subtitle }}</div>
</div>
</div>
</section>
<!-- Hero Area -->
<div class="container px-4 mx-auto ">
<section class="flex flex-row">
<div class="w-3/12 ">
<div class="text-right">
<div class="mb-6">{{ partial "posts/published-date.html" . }}</div>
<div>{{ partial "posts/modified-date.html" . }}</div>
</div>
<div class="text-right">
{{ partial "posts/reading-time.html" . }}
</div>
</div>
<div class="r-9/12">
{{ partial "posts/post-hero.html" . }}
</div>
</section>
</div>
<!-- Article In Brief-->
<!-- Article main content -->
<section class="container px-4 mx-auto">
<div class="grid grid-cols-12">
<div class="">
<!-- Audio Player -->
<div class="">{{ with (eq .Params.Audiopost "") }}
<p>nothing to display</p>
{{ else }}
{{ partial "audio.html" . }}
{{ end }}
</div>
<div class="mt-3 ml-1">
<p class="text-xs">Audio</p>
<p class="font-bold">Listen to the article</p>
</div>
</div>
<div class="col-span-9 col-start-4">
<article class="prose lg:prose-l">
{{ .Content }}
</article>
</div>
</div>
</section>
{{ end }}
and image :
<img src="{{ .Params.Image | absURL }}" alt="{{ .Title }}" loading="lazy" class="absolute">
{{ else }}
<p>pas d'image</p>
{{ end }}

Just Do this
.container {
position : relative;
right : 0;
}
This will make that container align Right . hop this works ..
and Elaborating your problem more will help us to fix your doubt

Related

How to manage image with different dimensions which i take from user in same card?

Images comes from the database which a user posted but the problem here images are with different dimensions within the card card.
If we fix the height and width pic does not remain in its original ratio.
But i want picture remain in original form but its height or width may change within the card like
{% for post in show_posts %}
<div class="col-md-6 col-lg-4 mb-4">
<div class="card listing-preview">
<img class="card-img-top" src="{{ post.photo.url }}" alt="">
<div class="card-body">
<div class="listing-heading text-center">
<h4 class="text-primary">{{ person.name }}</h4>
</div>
<hr>
<div class="row py-2 text-secondary">
<div class="col-12">
City: {{ post.city }}</div>
</div>
<div class="row py-2 text-secondary">
<div class="col-12">
Area: {{ post.area }}</div>
</div>
<hr>
<div class="row text-secondary pb-2">
<div class="col-12">
<i class="fas fa-clock"></i> {{ person.list_date timesince }}</div>
</div>
</div>
</div>
</div>
{% endfor %}
Set the maximum height of card-img-top.
The max-height CSS property sets the maximum height of an element. It
prevents the used value of the height property from becoming larger
than the value specified for max-height. - https://developer.mozilla.org
.card-img-top {
max-height: 300px;
width: auto;
}
for example if you wont all images would same size, you should .card{ height:300px; width:300px; }
.card img{width:100%; object-fit: contain;}

don't get the right size on small screen

I'm using bootstrap4 and Stream UI Kit for the user interface in my application but i don't get the right size of column on the small screen !!
example !
it's supposed to be one per line when we browse on mobile !! with col-md-4 you can check the demo
<!-- Campaigns Grid -->
<section class="pt-11 pb-6 bg-light">
<div class="container">
<div class="d-flex justify-content-between align-items-center mb-5">
<h2 class="h3 text-center">{{ trans('user.offers') }}</h2>
{{ trans('user.all') }}
</div>
<div class="row">
#foreach($offers as $demand)
<div class="col-md-4 mb-5">
<div class="card h-100 border-0 shadow">
<a href="{{ url('/campaign/'.$demand->id) }}" class="d-block bg-gradient rounded-top">
<img class="card-img-top hover-fade-out" src="{{ url('upload/campaign/'. $demand->cover .'/') }}" alt="{{ $demand->title }}" height="244">
</a>
<div class="card-body">
<a href="{{ url('/campaign/'.$demand->id) }}">
<h3>{{ $demand->title }}</h3>
</a>
<p>
{!! str_limit(strip_tags($demand->content), 128) !!}
</p>
</div>
<div class="card-footer d-flex">
#foreach($demand->categories as $category)
#if(App::isLocale('ar')) <a href="{{ url('/category/'.$category->id) }} " class="badge badge-pill badge-secondary mr-1" >{{ $category->title_ar }} </a>
#elseif(App::isLocale('fr')) {{ $category->title }}
#else {{ $category->title_en }}
#endif
#endforeach
</div>
</div>
</div>
#endforeach
</div>
</div>
</section>
<!-- End Campaigns Grid -->
You can use, col-md-4 along with all classes for devices.
Use this in one in line
class=“col-6 col-md-4 col-sm-4 col-lg-4 col-xl-4”
These classes themselves give responsive on all devices.
col - set mobile
col-md - set medium devices
col-sm - small
col-lg - large
col-xl - extra large
They will manage automatically.

Bootstrap: align 'card's horizontally as a single row

i am rendering the 4 items in a row through a for loop , the problem is that in the first line it renders 4 items but the rest of the items that come in the loop are rendered in separate line.
code
<div class="card-group">
{% for item in wt %}
<div class="card my-3 text-white bg-dark mb-3" style="width: 18rem;">
<img src="/media/{{item.thumbnail}}" class="card-img-top" alt="...">
<div class="card-body">
<h5 class="card-title">{{item.product_name}}</h5>
<p class="card-text">{{item.thumbnail_desc}}</p>
View Product
</div>
</div>
{% if forloop.counter|divisibleby:4 %}
</div>
{% endif %}
{% endfor %}
here i am using bootstrap and django framework... i also used "row" class but it also doesnt work very well
It should automatically do 4 to a row without having to add extra code:
{% for item in wt %}
<div class="card my-3 text-white bg-dark mb-3" style="width: 18rem;">
<img src="/media/{{item.thumbnail}}" class="card-img-top" alt="...">
<div class="card-body">
<h5 class="card-title">{{item.product_name}}</h5>
<p class="card-text">{{item.thumbnail_desc}}</p>
View Product
</div>
</div>
{% endfor %}
If not, try using class "col-md-3" instead of "my-3".
Let me know if this does the trick.
it worked by changing size of the card and also adding forloop's counter... the main problem was the size of the card , it was not fitting in the container
<h2 class="my-4 text-white bg-dark">New Arrivals</h2>
<div class="row">
{% for item in wt %}
<div class="card text-white bg-dark mb-3" style="width: 10rem;">
<img src="/media/{{item.thumbnail}}" class="card-img-top" alt="...">
<div class="card-body">
<h5 class="card-title">{{item.product_name}}</h5>
<p class="card-text">{{item.thumbnail_desc}}</p>
View Product
</div>
</div>
{% if forloop.counter|divisibleby:4 %}
</div>
<div class="row">
{% endif %}
{% endfor %}
</div>

Medium breakpoint not working in Foundation 6

I switched from bootstrap 4 to foundation 6 last week. So maybe it's due to my lack of experience with foundation.
But I have a problem with my breakpoints. The small breakpoint is never working. It is always showing the medium breakpoint. Here is an example of my code and a screenshot of the page I am making at width 320px.
Screenshot of issue
<div class="grid-container">
<section class="section">
<h1 class="text-center">{{ entry.title }}</h1>
<p class="text-center">{{ entry.subtext }}</p>
<div class="grid-x activities">
{% for activiteit in entry.activiteiten %}
<div class="small-12 medium-4 cell">
<div class="activity-card padding-2" style="background-color: {{ activiteit.kleurActiviteit }};">
<div class="activity-card__image text-center">
<div style="background-image: url({{ activiteit.activiteitafbeelding.first().getUrl() }});"></div>
</div>
<div class="activity-card__title text-center">
<h2>{{ activiteit.title }}</h2>
</div>
<div class="activity-card__subtext">
<p class="text-center">{{ activiteit.korteTekst }}</p>
</div>
</div>
</div>
{% endfor %}
</div>
</section>
I solved my own question. Had to set viewport meta tag in my html header.
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>

CSS Bootstrap 4 - making multiple line row with equal columns

I am trying to make a multiple line row with equal width columns with Bootstrap 4. This is the loop where I am creating this columns:
<div class="row video-section">
<div class="col-md-12">
#if(!(count($videos) > 0))
<p>{{ $player->first_name }} {{ $player->last_name }} has no videos yet.</p>
#else
#foreach($videos as $video)
<div class="col-md-3 profile-video-box">
<a href="/player/video/{{ $video->uid }}/{{ $video->player->fullName }}">
<div class="card bg-dark text-white">
<img src="{{ $video->getThumbnail() }}" class="card-img"/>
<div class="card-img-overlay">
<div class="play-icon-wrapper">
<i class="ion-ios-play"></i>
</div>
<div class="card-content">
<h5 class="card-title">{{ $video->title != '' ? $video->title : 'Untitled' }}
</h5>
<p class="card-text">{{ $video->created_at->diffForHumans() }}
</p>
</div>
</div>
</div>
</a>
</div>
#endforeach
</div>
</div>
But, then the each column takes up the whole row, since it gets the margin right to take up the rest of the space in the row. How can I fix that and create multiple line row?
Update
Here is the fiddle.
Try with this code and fiddle
<div class="row video-section ">
<div class="container">
<div class="row">
<div class="col-md-3 profile-video-box">
123
</div>
<div class="col-md-3 profile-video-box">
456
</div>
<div class="col-md-3 profile-video-box">
759
</div>
</div>
</div>
</div>
Don't use <div class="col-md-12"> inside your <div class="row video-section"> element. Instead confine <div class="col-md-12"> to only your <p> tag, like:
<div class="row video-section">
#if(!(count($videos) > 0))
<div class="col-md-12">
<p>{{ $player->first_name }} {{ $player->last_name }} has no videos yet.</p>
</div>
#else
#foreach($videos as $video)
<div class="col-md-3 profile-video-box">
<a href="/player/video/{{ $video->uid }}/{{ $video->player->fullName }}">
<div class="card bg-dark text-white">
<img src="{{ $video->getThumbnail() }}" class="card-img"/>
<div class="card-img-overlay">
<div class="play-icon-wrapper">
<i class="ion-ios-play"></i>
</div>
<div class="card-content">
<h5 class="card-title">{{ $video->title != '' ? $video->title : 'Untitled' }}
</h5>
<p class="card-text">{{ $video->created_at->diffForHumans() }}
</p>
</div>
</div>
</div>
</a>
</div>
#endforeach
</div>
Hope this helps!

Resources