How to align images in one row? - html

I am trying to align images in one row but it doesn't seem to be working. I have tried flex but the last logo is still on another row.
<section id="clients" class="clients clients">
<div class="container">
<div class="row content">
<div class="col-3">
<img src="logo1" class="img-fluid srl" alt="">
</div>
<div class="col-3">
<img src="logo2" class="img-fluid" alt="">
</div>
<div class="col-3">
<img src="logo3" class="img-fluid" alt="">
</div>
<div class="col-3">
<img src="logo4" class="img-fluid" alt="">
</div>
<div class="col-2">
<img src="logo5" class="img-fluid" alt="">
</div>
</div>
</div>
.clients {
background: #f3f9fd;
padding: 0px 0px;
text-align: center;
}
.clients .col-lg-2 {
display: flex;
align-items: center;
justify-content: center;
}
.clients img {
width: 70%;
-webkit-filter: grayscale(100);
filter: grayscale(100);
transition: all 0.4s ease-in-out;
display: inline-block;
padding: 10px 0;
}
.clients img:hover {
-webkit-filter: none;
filter: none;
transform: scale(1.1);
}
As you can see the last logo is in its own row but I want it to be on the same row as the rest of them but i cant seem to do this?
Thanks

Your idea was flawed in using col-3
bootstrap grid system is divided into 12 spaces
col-1 uses 1 space
col-2 uses 2 spaces
an so on
Your images all have col-3 and there is 5 of them which is taking 15 "spaces" which is more than 12 thats why last element is moved down.
When you check bootstrap documentation for grid system you will find that you don't have to speciy how many spaces col needs to take.
You can use .col which will take as many width as it need for all elements to fill whole parent element
.clients {
background: #f3f9fd;
padding: 0px 0px;
text-align: center;
}
.clients .col {
display: flex;
align-items: center;
justify-content: center;
}
.clients img {
width: 70%;
/* just for presentation*/ min-height: 50px;
/* just for presentation*/ background-color: red;
-webkit-filter: grayscale(100);
filter: grayscale(100);
transition: all 0.4s ease-in-out;
display: inline-block;
padding: 10px 0;
}
.clients img:hover {
-webkit-filter: none;
filter: none;
transform: scale(1.1);
}
<!-- CSS only -->
<link href="https://cdn.jsdelivr.net/npm/bootstrap#5.0.1/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-+0n0xVW2eSR5OomGNYDnhzAbDsOXxcvSN1TPprVMTNDbiYZCxYbOOl7+AMvyTG2x" crossorigin="anonymous">
<section id="clients" class="clients clients">
<div class="container">
<div class="row content">
<div class="col">
<img src="logo1" class="img-fluid srl" alt="">
</div>
<div class="col">
<img src="logo2" class="img-fluid" alt="">
</div>
<div class="col">
<img src="logo3" class="img-fluid" alt="">
</div>
<div class="col">
<img src="logo4" class="img-fluid" alt="">
</div>
<div class="col">
<img src="logo5" class="img-fluid" alt="">
</div>
</div>
</div>
</section>

Related

text does not want to be under the image. using bootstrap

Hi guys do you know how to make this text under the image. i've tried use absolute on the text and it's work but when i test the responsive text gonna be the bottom of content not under the picture.
#sorryforbadenglish
.fitur {
padding: 15px 0;
text-align: center;
}
.fitur .btn-get-started {
font-family: "Roboto", sans-serif;
text-transform: uppercase;
font-weight: 500;
font-size: 14px;
letter-spacing: 1px;
display: inline-block;
padding: 10px 28px;
border-radius: 4px;
transition: 0.5s;
color: #fff;
background-image: url("../img/gplay.png");
background-size: cover;
width: 210px;
height: 61px;
}
.fitur .col-half-offset {
margin-left: 4.166666667%
}
.fitur p.sub {
font-size: 16px;
font-family: "Ubuntu", sans-serif;
font-weight: 700;
}
.fitur img {
max-width: 200%;
transition: all 0.4s ease-in-out;
display: inline-block;
padding: 15px 0;
}
.fitur img:hover {
transform: scale(1.15);
}
#media (max-width: 768px) {
.fitur img {
max-width: 100%;
}
}
#media (min-width: 1024px) {}
#media (max-width: 500px) {}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" rel="stylesheet"/>
<section id="fitur" class="fitur section-bg">
<div class="container" data-aos="zoom-in">
<div class="section-title">
<p style="margin-top: 100px;">Fitur</p>
<h3>Aplikasi</h3>
</div>
<div class="row">
<div class="col-lg-2 d-flex align-items-center justify-content-center">
<img src="assets/img/aplikasi/01.png" class="img-fluid" alt="">
<p class="sub">Jual Sampah</p>
</div>
<div class="col-lg-2 col-half-offset d-flex align-items-center justify-content-center">
<img src="assets/img/aplikasi/02.png" class="img-fluid" alt="">
<p class="sub">Harga Real Time</p>
</div>
<div class="col-lg-2 col-half-offset d-flex align-items-center justify-content-center">
<img src="assets/img/aplikasi/05.png" class="img-fluid" alt="">
<p class="sub">Transaksi Terdata</p>
</div>
<div class="col-lg-2 col-half-offset d-flex align-items-center justify-content-center">
<img src="assets/img/aplikasi/06.png" class="img-fluid" alt="">
<p class="sub">Layanan Komunikasi</p>
</div>
<div class="col-lg-2 col-half-offset d-flex align-items-center justify-content-center">
<img src="assets/img/aplikasi/07.png" class="img-fluid" alt="">
<p class="sub">Rangkuman Transaksi</p>
</div>
</div>
<div class="d-flex">
</div>
</div>
</section>
the result is :
The text is next to the image, can you help me how to take it under the image ?
Add flex-column to the parent div which contains the image and text. Like this
<div class="col-lg-2 d-flex align-items-center justify-content-center flex-column">
<img src="assets/img/aplikasi/01.png" class="img-fluid" alt="">
<p class="sub">Jual Sampah</p>
</div>
By default the flex direction is row and it needs to be set to column so that the image and text are stacked on top of each other

Creating a text overlay when hovering over image

I have these images in a simple responsive grid that I am trying to add an overlay for. When I hover on an image, id like to have 3 or 4 lines that give a general description. By default, the images show, and when I hover id like the text to appear ~ how might I do this?
Here is the current code that I have
<div class="container">
<div class="product-item">
<img src="https://images.unsplash.com/photo-1587202372583-49330a15584d?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=500&q=60 " alt=" ">
</div>
<div class="product-item">
<img src="https://images.unsplash.com/photo-1555485086-b0d5d518b225?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=500&q=60 " alt=" ">
</div>
<div class="product-item">
<img src="https://images.unsplash.com/photo-1555404910-2c3475578b36?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=500&q=60 " alt=" ">
</div>
</div>
.home-body .container {
display: flex;
flex-wrap: wrap;
justify-content: center !important;
margin: 5em 0 0 0;
}
.home-body img {
margin: 5px;
transition: all 1s;
}
.home-body img:hover {
transform: scale(1.05);
transition-duration: .3s;
filter: grayscale(20%);
opacity: 90%;
cursor: pointer;
}
.product-item {
background-color: #212121;
margin: 5px;
}
And here is what I think I could do, but dont know how to implement it with html/css
<div class="container ">
<img src="img.jpg" alt=" ">
<div class="overlay-text">
<h3>Random Title</>
<p>Random description</p>
<p>Random description</p>
<p>Random description</p>
</div
</div>
The simplest solution would be to:
Add 4 text tags which are used for the description you mentioned and assign a class to them.
Add display: none; to the class.
Add, for instance, display: block; to :hover of your class.
HTML:
<div class="container ">
<img src="img.jpg" alt=" ">
<div class="overlay-text">
<h3>Random Title</>
<p>Random description</p>
<p>Random description</p>
<p>Random description</p>
</div
</div>
CSS:
.overlay-text {
display: none;
}
.overlay-text:hover {
display: block;
}
Additionally:
If you want your image to be the background of the div, then remove
<img src="img.jpg" alt=" ">
from your HTML and add this to your overlay-text class in CSS:
background-image: url("img.jpg");
Is this what you are looking for.
.home-body .container {
display: flex;
flex-wrap: wrap;
justify-content: center !important;
margin: 5em 0 0 0;
}
.home-body img {
margin: 5px;
transition: all 1s;
}
.home-body img:hover {
transform: scale(1.05);
transition-duration: .3s;
filter: grayscale(20%);
opacity: 90%;
cursor: pointer;
}
.product-item {
background-color: #212121;
margin: 5px;
position: relative;
}
.home-body a .hover-text {
display: none;
}
.home-body a:hover .hover-text {
display: block;
position: absolute;
text-align: center;
color: #fff;
left: 10%;
top: 50%;
}
<body class="home-body">
<div class="container">
<div class="product-item">
<a href="products.html"><img src="https://images.unsplash.com/photo-1587202372583-49330a15584d?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=500&q=60 " alt=" ">
<div class="hover-text">
<h3>Gaming PC</h3>
<p>This is a gaming pc. This is a gaming pc. This is a gaming pc.</p>
</div>
</a>
</div>
<div class="product-item">
<a href="products.html"><img src="https://images.unsplash.com/photo-1555485086-b0d5d518b225?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=500&q=60 " alt=" ">
<div class="hover-text">
<h3>Gaming PC</h3>
<p>This is a gaming pc. This is a gaming pc. This is a gaming pc.</p>
</div>
</a>
</div>
<div class="product-item">
<a href="products.html"><img src="https://images.unsplash.com/photo-1555404910-2c3475578b36?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=500&q=60 " alt=" ">
<div class="hover-text">
<h3>Gaming PC</h3>
<p>This is a gaming pc. This is a gaming pc. This is a gaming pc.</p>
</div>
</a>
</div>
</div>
</body>

change src image on hover using css

2 image appear in same time, up and down.
I want hover image display none.
Hover image is appear below primary image.
Primary image is hide when hover.
Seems like dont work. and really need help on this.
.card-img-top {
border-radius: 0;
height: 250px;
width: 100%;
top: 50%;
left: 50%;
transform: translate(0%, 0%);
object-fit: cover;
margin-bottom: 20px;
}
.card a img {
display: block;
}
.card a:hover img:first-child {
display: none;
}
<div class="card col-12 col-md-6 col-sm-12 col-lg-6 col-xl-4">
<a href="#">
<img class="card-img-top" src="images/True Blue Asia.jpg"/>
<img class="card-img-top" src="images/Asia Bagus.jpg"/>
<div class="card-img-overlay d-table-cell align-middle">
<p>true blue asia</p>
</div>
<div class="card-body">
<div class="row">
<div class="col-12 col-md-3">
<div class="card-date">Oct 2019</div>
</div>
<div class="col-12 col-md-9">
<div class="card-title">Roots, Heritage, Authenticity</div>
<div class="card-content">Asia’s myriad cultures manifest in practices derived from traditional value systems.</div>
</div>
</div>
</div>
</a>
</div>
<div class="card">
<img src="/image_displayed_as_default" class="hover-hidden"/>
<img src="/image_displayed_when_hover" class="hover-only"/>
</div>
.card img {
opacity: 1;
transition: opacity 200ms;
}
.card:hover img.hover-hidden,
.card:not(:hover) img.hover-only {
opacity: 0;
}
You are looking for this
Pure CSS solution
#aks {
width:0px;
height:0px;
background:url('http://dummyimage.com/100x100/000/fff');
padding:50px;
}
#aks:hover {
background: url('http://dummyimage.com/100x100/eb00eb/fff');
}
<img id="aks" src="http://dummyimage.com/100x100/000/fff"/>
Your code solution
Issue i you are not hide second image initially
.card-img-top {
border-radius: 0;
height: 250px;
width: 100%;
top: 50%;
left: 50%;
transform: translate(0%, 0%);
object-fit: cover;
margin-bottom: 20px;
}
.card a img {
display: block;
}
.card a:hover img:first-child {
display: none;
}
.card a .card-img-below{
display: none;
}
.card a:hover .card-img-below {
display: block;
}
a{
display:block;
}
<div class="card col-12 col-md-6 col-sm-12 col-lg-6 col-xl-4">
<a href="#">
<img class="card-img-above" src="https://cdn4.iconfinder.com/data/icons/imoticons/105/imoticon_15-128.png"/>
<img class="card-img-below" src="https://cdn4.iconfinder.com/data/icons/imoticons/105/imoticon_12-128.png"/>
<div class="card-img-overlay d-table-cell align-middle">
<p>true blue asia</p>
</div>
<div class="card-body">
<div class="row">
<div class="col-12 col-md-3">
<div class="card-date">Oct 2019</div>
</div>
<div class="col-12 col-md-9">
<div class="card-title">Roots, Heritage, Authenticity</div>
<div class="card-content">Asia’s myriad cultures manifest in practices derived from traditional value systems.</div>
</div>
</div>
</div>
</a>
</div>
Change the image url

How to place the same image at the top and at the bottom of the same column?

So the title pretty much explains my problem. For now, I have my image placed at the top of the column and at the same time I need it to be at the bottom. How can I do this?
My Codepen
HTML
<div class="content">
<div class="row">
<div class="col-md-10 first-column"></div>
<div class="col-md-2 back-to-blog">
<a href="/">
<img class="img-responsive" src="https://api.asm.skype.com/v1/objects/0-neu-d1-6d077751650ba9cb23f065b16e4d4581/views/imgpsh_fullsize">
</a>
</div>
</div>
</div>
</div>
CSS
.content {
padding: 0 35px;
}
.first-column {
border: 1px solid;
height: 200px;
}
Flexbox can do that:
.content {
padding: 0 35px;
}
.row {
display: flex; /* columns now equal height */
}
.first-column {
border: 1px solid;
height: 200px;
flex: 10; /* replicates md-10 */
}
.back-to-blog {
flex: 2; /* replicates md-2 */
display: flex;
flex-direction: column; /* sets directionality */
justify-content: space-between; /* separates elements across direction */
}
a {
display: block;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet" />
<div class="content">
<div class="row">
<div class="col-md-10 first-column"></div>
<div class="col-md-2 back-to-blog">
<a href="/">
<img class="img-responsive" src="http://lorempixel.com/image_output/abstract-q-c-25-25-3.jpg">
</a>
<a href="/">
<img class="img-responsive" src="http://lorempixel.com/image_output/abstract-q-c-25-25-3.jpg">
</a>
</div>
</div>
</div>
</div>
Here is another way if you want to stick into Bootstrap column classes:
HTML:
<div class="content">
<div class="row">
<div class="col-xs-2 col-sm-10 col-md-10 first-column">aaa</div>
<div class="col-xs-2 col-sm-2 col-md-2 back-to-blog">
<img class="img-responsive" src="https://api.asm.skype.com/v1/objects/0-neu-d1-6d077751650ba9cb23f065b16e4d4581/views/imgpsh_fullsize">
<img class="img-responsive" src="https://api.asm.skype.com/v1/objects/0-neu-d1-6d077751650ba9cb23f065b16e4d4581/views/imgpsh_fullsize">
</div>
</div>
</div>
</div>
CSS:
.content {
padding: 0 35px;
}
.first-column {
border: 1px solid;
height: 200px;
}
.back-to-blog{
height: 200px;
}
.btm-link{
position: absolute;
bottom: 0;
}
Codepen:
http://codepen.io/anon/pen/xZyGoQ

How to get better control over responsive images break point and alignment with BS3

I am trying to control some responsive images placed in a grid.
Unfortunately 2 annoying things occur when the viewport is changed in width:
The images which starts out as 4 in a row, quickly becomes 1 in a row even though there is space enough for 2-3 in the viewport.
The images are not positioned in center when 1 in a row.
HTML
<section>
<div class="container">
<div class="row">
<div class="col-lg-8 col-lg-offset-2 text-center">
<h2>Image test</h2>
<hr class="line-color"></hr>
</div>
</div>
<div class="row team-images">
<div class="col-md-3">
<div class="team-item">
<div class="team-text">
<h3>John Doe</h3>
<h4>COO</h4>
</div>
<div class="team-image-overlay"></div>
<img src="http://placehold.it/400x400" class="img-responsive" alt="" />
</div>
</div>
<div class="col-md-3">
<div class="team-item">
<div class="team-text">
<h3>Moe Joe</h3>
<h4>COO</h4>
</div>
<div class="team-image-overlay"></div>
<img src="http://placehold.it/400x400" class="img-responsive" alt="" />
</div>
</div>
<div class="col-md-3">
<div class="team-item">
<div class="team-text">
<h3>Jimbo Joe</h3>
<h4>COO</h4>
</div>
<div class="team-image-overlay"></div>
<img src="http://placehold.it/400x400" class="img-responsive" alt="" />
</div>
</div>
<div class="col-md-3">
<div class="team-item">
<div class="team-text">
<h3>Jimmy Joe</h3>
<h4>COO</h4>
</div>
<div class="team-image-overlay"></div>
<img src="http://placehold.it/400x400" class="img-responsive" alt="" />
</div>
</div>
</div>
</div>
</section>
CSS
body {
margin: 10px;
}
.team-images img {
max-height:300px;
width:auto;
}
.team-text {
position: absolute;
width: 100%;
bottom: 0;
text-align: center;
background-color:rgba(0, 0, 0, 0.4);
}
.team-text h3 {
margin-top:5px;
font-weight: 300;
margin-bottom: 0;
text-transform: none;
}
.team-text h4 {
margin-bottom:5px;
margin-top: 0;
padding-top: 0;
font-weight: 200;
font-size: 1em;
text-transform: none;
}
.team-item {
position: relative;
display:inline-block;
margin-bottom:10px;
}
.team-images .team-image-overlay {
position: absolute;
top: 0;
width: 100%;
height: 100%;
background-color: rgba(41, 128, 185, 0.4);
color: #fff;
-webkit-transition: all ease .5s;
-moz-transition: all ease .5s;
transition: all ease .5s;
}
.team-images .team-image-overlay:hover {
background: rgba(24, 188, 156, 0);
}
DEMO: https://jsfiddle.net/DTcHh/7189/
On your columns, you only specified col-md-3 which will only trigger during medium to large resolutions.
You can set instead col-md-3 col-sm-3 or just col-sm-3 so it will also trigger on smaller res.
Regarding the images not positioned center, you can make it by setting text-align:center on their container.
.team-images > div {
text-align:center;
}
Working fiddle : https://jsfiddle.net/1L4fgdf5/3/
In response to your comment below, if you don't want to use scaffolding use media queries on css intead.
#media (min-width: 992px) and (max-width: 1199px) {
.team-images .col-md-3 {
width: 50%;
}
}
Working fiddle: https://jsfiddle.net/da9b30fn/