Same height for thumbnail columns in Bootstrap 3 - html

I've been reading lot of answers on how to have same height columns within the same row, but none seems to work in my case. I know the solution is probably something really dumb, but I cannot figure it out...
So, first I created a style.css and imported it in my index.php this way (I also include the other style reference I am actually using and the important part of the code below):
index.php
<link rel="stylesheet" href="./static/style.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
...
<div class="container-fluid">
<div class="row">
<div class="col-md-4">
<div class="thumbnail">
<img src="./img/animazione.jpg" alt="Animazione" style="width:100%">
<div class="caption">
<h2>Some text COL2</h2>
</div>
</div>
</div>
<div class="col-md-4">
<div class="thumbnail">
<img src="./img/rinnovabili.jpg" alt="Rinnovabili" style="width:100%">
<div class="caption">
<h2>Some text COL2</h2>
</div>
</div>
</div>
<div class="col-md-4">
<div class="thumbnail">
<img src="./img/rugby.jpg" alt="Rugby" style="width:100%">
<div class="caption">
<h2>Some text COL3</h2>
</div>
</div>
</div>
</div>
My style.css is like (as proposed here):
style.css
.equal {
display: flex;
display: -webkit-flex;
flex-wrap: wrap;
}
After that, I tried to replace <div class="row"> with <div class="row equal"> but nothing happened: the columns are still each a different height. I also tried to set the first row of my style.css to .row.equal{ but still with no luck.
I am using FireFox ver. 53. When i open the Developer Tools, I can see that display: flex; in my css is ignored (it's ruled out). I guess it is something related to flexbox, but I am a novice and I really don't know how to solve this problem.
I also created a bootply as suggested. Hope it will help understanding my point.

The columns are equal height, but the thumbnails inside the columns are not filling the height. Just set the height...
.row.equal {
display: flex;
display: -webkit-flex;
flex-wrap: wrap;
height: 100%;
}
.thumbnail {
height: 100%;
}
https://www.bootply.com/8wQiUUKL53

I guess the flex property was getting overriding by the bootstrap classes and can be resolved by '!important' in your custom css.
.target-class{
display: flex !important;
}
But you can simplify the code by removing the predefined thumbnail class and styling it in your own way.
Display your parent class as flex and align your children as 'stretch' (will give the height equal to the height of the parent div).
.parent {
background: lightgrey;
display: flex;
}
.child {
align-items: stretch;
flex: 1;
background: #fff;
margin: 10px;
padding-top: 10px;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<div class="container-fluid">
<div class="row">
<div class="col-xs-12">
<div class="parent">
<div class="col-xs-4 child">
<img src="https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSj8ddwNjLjFB_PoOLhcXHdZUbyCk0ZbhSYi1Vzf2nZo4qDiA2h" style="width:100%">
<div class="caption">
<h2>Some text COL2 some text</h2>
</div>
</div>
<div class="col-xs-4 child">
<img src="https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSj8ddwNjLjFB_PoOLhcXHdZUbyCk0ZbhSYi1Vzf2nZo4qDiA2h" style="width:100%">
<div class="caption">
<h2>Some text COL2 some more text</h2>
</div>
</div>
<div class="col-xs-4 child">
<img src="https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSj8ddwNjLjFB_PoOLhcXHdZUbyCk0ZbhSYi1Vzf2nZo4qDiA2h" style="width:100%">
<div class="caption">
<h2>Some text COL3</h2>
</div>
</div>
</div>
</div>
</div>
</div>

Related

CSS Instagram Image Box Layout

I am making a Instagram layout provided below, basically, the image/boxes have aspect ratio of 1:1 (just diffrent sizes), I am using Bootstrap 4 and SCSS mixin for aspect ratio.
My issue is I cannot align properly the 4 boxes surrounding the big box on the middle and the spacing on the middle box.
I used absolute positioning and flexbox, something like below but I am not sure if this is the right approach.
.ig {
&-wrapper {
display: flex;
align-items: flex-end;
justify-content: space-between;
}
&-item-1,
&-item-2 {
width: 180px;
height: 180px;
#include aspect-ratio(180px, 180px);
}
}
Here is the demo link to what I have started
https://codepen.io/johndavemanuel/pen/WNQgzZO
Solved!
Switch to bootstrap columns instead of flexbox
<div class="row ig-row-1">
<div class="col-1 offset-3 ig-col">
<div class="ig-row-1-item-1 bg-primary">
<img src="https://source.unsplash.com/600x600/?boxing" alt="">
</div>
</div>
<div class="col-2">
<div class="ig-row-1-item-2 bg-primary">
<img src="https://source.unsplash.com/600x600/?boxing" alt="">
</div>
</div>
<div class="col-1">
<div class="ig-row-1-item-3 bg-primary">
<img src="https://source.unsplash.com/600x600/?boxing" alt="">
</div>
</div>
</div>
https://codepen.io/johndavemanuel0528/full/YzyOJvJ

Aligning divs and images vertically

I have a couple of images
mockleft.png - 1228x500px
mockright.png - 1825x335px
My code is as below..
<head>
<link href="css/bootstrap.min.css" rel="stylesheet">
</head>
<body id="home">
<div class="intro">
<div class="row">
<div class="col-xs-5" style="background-color:blue">
<img src="img/mockleft.png" alt="logo" style="width:100%;">
</div>
<div class="col-xs-1"></div>
<div class="col-xs-6" style="background-color:red;">
<img src="img/mockright.png" alt="logo" style="width:100%;">
</div>
</div>
</div>
</body>
The output is as below..
I wish for two things..
a) The left div with blue background should be same height as right div with red background and vice versa.
b)Once the right div with red background becomes same size with the left one, I want the mockright.png image to be vertically aligned at bottom of the right div.
I tried the vertical-align css to both the div as well as image without success.
All help is sincerely appreciated
Thanks
You could do it with flexbox. If you use Bootstrap 4 as #Pete suggests in the comments, you could achieve the same, since it uses flexbox.
JSFiddle Demo
.row {
display: flex;
}
.col-xs-1 {
width: 10%;
}
.col-xs-5 {
display: flex;
flex-direction: column;
width: 40%;
background: blue;
justify-content: flex-end;
}
.col-xs-6 {
width: 50%;
background: red;
}
<div class="row">
<div class="col-xs-5">
<img src="https://placekitten.com/600/400" alt="logo" style="width:100%;">
</div>
<div class="col-xs-1"></div>
<div class="col-xs-6">
<img src="https://placekitten.com/600/400" alt="logo" style="width:100%;">
</div>
</div>
a) Assuming you need to use Bootstrap 3, what you can do is use one of the options provided to make the columns the same height:
How can I make Bootstrap columns all the same height?
b) For that part, use auto margin:
<img src="img/mockright.png" alt="logo" style="width:100%; margin-top: auto;">
Hope it helps :)

Unable to align div content

I am developing an application using Vue.js and Bootstrap. I am looking to develop a folder to look like this:
But, I am unable to align the contents to make sure that it looks like in the above picture.
The picture currently looks like this:
Here is the code:
<div class="col-xl-3 col-md-6">
<stats-card>
<div slot="header" class="folderRectangle">
<div class="row">
<div class="col-3">
<div class="clearfix">
<i class="material-icons" id="folder-image">folder</i>
</div>
</div>
<div class="col-9">
<div class="clearfix" style="position: relative">
<div>
<p style="text-align: left">Folder Name</p>
</div>
<div>
<p style="text-align:left">20 files</p>
</div>
</div>
</div>
</div>
</div>
</stats-card>
</div>
What wrong am I doing? How do I make sure that the folder icon aligns to the top and text floats to the center?
Instead of using .row and .col-*, you can use the media object already available in Bootstrap to produce this layout.
/* demo only */
.media {
border: 1px solid #ddd;
padding: 1.5rem;
margin: 1rem;
}
img {
max-width: 25px;
}
.media-body {
font-size: 0.75rem;
}
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/css/bootstrap.min.css" integrity="sha384-GJzZqFGwb1QTTN6wy59ffF1BuGJpLSa9DkKMp0DgiMDm4iYMj70gZWKYbI706tWS" crossorigin="anonymous">
<div class="media">
<img class="mr-3" src="https://png.pngtree.com/element_our/png/20181213/folder-vector-icon-png_267455.jpg" alt="Generic placeholder image">
<div class="media-body">
<h6 class="mt-0 mb-1">Folder name</h6>
<div>20 files</div>
</div>
</div>
The best possible way to achieve what you are trying is to use CSS Flex property.
Just give display flex to the parent (col-9) in your case.
Provide align items to be center.
and at last flex alignment to row.
this will make you achieve the above design
You can read about CSS flexbox more here
https://www.w3schools.com/css/css3_flexbox.asp

text does not vertically align with image

Good day, as the title says, I am having issues with aligning the text in the exact center of my image. I tried adding a class with the css vertical-align:middle with no effect. Also, I tried using the span class to surround the text that will be centered. Both the image and the text are encased in a bootstrap grid. Any help will be appreciated thank you.
HTML/Bootstrap:
<div class="container-fluid">
<div class="row">
<div class="col-md-3">
<img src="img/mission-mywhitecard.jpg" class="img-responsive align_text">
</div>
<div class="col-md-9 justify_text">
<span>
<h2 class="med_bg">OUR MISSION</h2>
<p class="mv_font">“To provide a mutually-beneficial platform for partners through high-quality, lower cost and friendly access to health, wellness and beauty.”</p>
</span>
</div>
</div>
</div>
CSS:
.align_text {
vertical-align: middle;
}
Considering you are using bootstrap4, you can achieve that using the class .align-items-center, or use display:flex as stated by others :)
img {
background: gray;
height: 250px;
display: block;
max-width: 100%;
}
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css">
<div class="container-fluid">
<div class="row align-items-center">
<div class="col-3">
<img src="img/mission-mywhitecard.jpg" class="img-responsive align_text">
</div>
<div class="col-9 justify_text">
<h2 class="med_bg">OUR MISSION</h2>
<p class="mv_font">“To provide a mutually-beneficial platform for partners through high-quality, lower cost and
friendly access to health, wellness and beauty.”</p>
</div>
</div>
</div>
I believe this produces what you ask for. It is using 2 flexboxes:
First one (.row) to put the image and text next to each other in a responsive way;
Second one (.col-md-9) to position the span in the center
html,
body {
width: 100%;
}
.row {
display: flex;
width: 100%;
}
.row>* {
flex: 1; /* Allow the flex items to grow and shrink */
}
.col-md-9 {
display: flex;
justify-content: center;
align-items: center;
}
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" rel="stylesheet" />
<div class="container-fluid">
<div class="row">
<div class="col-md-3">
<img src="https://via.placeholder.com/100x300" class="img-responsive align_text">
</div>
<div class="col-md-9">
<span>
<h2 class="med_bg">OUR MISSION</h2>
<p class="mv_font">“To provide a mutually-beneficial platform for partners through high-quality, lower cost and friendly access to health, wellness and beauty.”</p>
</span>
</div>
</div>
</div>
You can aslo use align-self-center in column div class without any height of image and other css also add larger image no design change when you use align-self-center in column div no need set image height
.align_text {
vertical-align: middle;
}
img {
max-width: 100%;
}
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css">
<div class="container-fluid">
<div class="row">
<div class="col-md-3">
<img src="http://placekitten.com/1000/500" class="img-responsive align_text">
</div>
<div class="col-md-9 justify_text align-self-center">
<span>
<h2 class="med_bg">OUR MISSION</h2>
<p class="mv_font">“To provide a mutually-beneficial platform for partners through high-quality, lower cost and friendly access to health, wellness and beauty.”</p>
</span>
</div>
</div>
</div>

Bootstrap columns with stacked images: need to have same column height

I have a Bootstrap section with stacked images and the issue is that I want the second and third columns to always have the same height as the first column. I can't seem to find a solution for the second and third column because they keep fluctuating in height as I change to different view sizes. It would be ideal to have them always align to the bottom and top.
.gallery {
min-height: 980px;
}
.gallery .row{
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
}
<div class="container-fluid gallery">
<div class="row">
<div class="col-sm-5">
<img src="http://lorempixel.com/528/980/technics" class="img-responsive">
</div>
<div class="col-sm-4">
<img src="http://lorempixel.com/409/490/technics" class="img-responsive">
<img src="http://lorempixel.com/409/490/technics" class="img-responsive">
</div>
<div class="col-sm-3">
<img src="http://lorempixel.com/324/327/technics" class="img-responsive">
<img src="http://lorempixel.com/324/327/technics" class="img-responsive">
<img src="http://lorempixel.com/324/327/technics" class="img-responsive">
</div>
</div>
</div>
Here is the Bootply: http://www.bootply.com/mb2Ez6G7r8
Hi Paul you can resolve in that way, i see that you use boostrap you dont need the property flex in your css.
<div class="row">
<div class="col-sm-5">
<img src="https://www.jssor.com/demos/img/paint/01.jpg">
</div>
<div class="col-sm-4">
<img src="https://www.jssor.com/demos/img/paint/02.jpg">
<img src="http://lorempixel.com/409/490/technics" class="img-responsive">
</div>
<div class="col-sm-3">
<img src="https://www.jssor.com/demos/img/paint/06.jpg" class="img-responsive">
and your css
.gallery {
min-height: 980px !important;}
dont forget add bootrap in your html
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">
i explain why you dont need flex, Boostrap make your thml responsive with class .row and you can fill this with 12 columns that is why you have col-sm-(Number) in your case 5+4+3=12 if you want you can read more in this link grid systemn
.column-sm-4{
display: flex;
flex-direction: row;
}
If height is an issue you should probably use background-image with css instead of <img> element.
Hope this will solve the issue.