Bootstrap Thumbnails Leave gaps in between - css

I'm trying to make a grid of Boostrap unevenly sized thumbnails. But some thumbnails are uneven, resulting in huge gaps between some rows.
I don't have any styling on the thumbnails.
Is there a way to fix it without adding something like Masonry/Isotope/Salvattore?

You can use two <div> or two .row tags like this:
<div class="row">
<div class="col-md-4">
<div class="thumbnail">
<img src="..." alt="...">
<div class="caption">
<p>Thumbnail caption</p>
</div>
</div>
</div>
<div class="col-md-4">
<div class="thumbnail">
<img src="..." alt="...">
<div class="caption">
<p>Thumbnail caption</p>
</div>
</div>
</div>
<div class="col-md-4">
<div class="thumbnail">
<img src="..." alt="...">
<div class="caption">
<p>Thumbnail caption</p>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-4">
<div class="thumbnail">
<img src="..." alt="...">
<div class="caption">
<p>Thumbnail caption</p>
</div>
</div>
</div>
<div class="col-md-4">
<div class="thumbnail">
<img src="..." alt="...">
<div class="caption">
<p>Thumbnail caption</p>
</div>
</div>
</div>
<div class="col-md-4">
<div class="thumbnail">
<img src="..." alt="...">
<div class="caption">
<p>Thumbnail caption</p>
</div>
</div>
</div>
</div>
For more info visit Example: Stacked-to-horizontal.

The cleanest way to fix your layout is to use a masonry type of layout. It will allow for the smoothest look and be a very fluid and responsive layout when dealing with mixed sized media. Though if you are in complete control of the data/images being placed on the site I would suggest creating each image to be identical in size and type. If you would like I can provide an example I have created using a masonry type of layout with thumbnails and Bootstrap.
Edit to add example code:
/* CSS styles */
.row {
-moz-column-width: 12em;
-webkit-column-width: 12em;
-moz-column-gap: 1em;
-webkit-column-gap:1em;
column-width: 12em;
column-gap: 1em;
column-fill: balance;
width: 100%;
}
/* Outer div block */
.section-block {
display: block;
padding: .25rem;
width: 100%;
}
/* Inner div block */
.section-item {
position:relative;
display: inline-block;
width: 100%;
}
.section-item img{
width: 100%;
}
//Wrapper for each img you are adding
<div class='section-block'>
<div class='section-item'>
<div>
<a href='#' class='thumbnail' data-toggle='modal' data-target='#id'>
<img src='/imgs/image.jpg'>
<p class='caption'>Image Caption</p>
</a>
</div>
</div>
</div>
I used this in conjunction with php to get all my images from a db then I looped over each image and echo'd to the page with the above syntax. This should work without having to use any additional js libraries beyond what you are using for bootstrap. This gives you a very responsive masonry style of layout that works in modern browsers.

Related

CSS how to align different size images with text inside row?

Need to align four different height (beetween 160-180px) svg images with text under them.
Images should be placed in line at sight and I don't know how to make strict align short text under them in one line like on screenshot.
Thanks!
UPD: Sorry for inconvinient information, thought that this question is quite typical for those who know css good.
Here is my html and css. Also I'm using bootstrap rows.
<div class="did-you-know">
<div class="row items">
<div class="col-lg-3 col-xs-6">
<div class="icon">
<img src="/img/mswa/inline-wa.svg"/>
</div>
<div class="title text-poppins">
<p>We’re from WA</p>
<p>{like you!}</p>
</div>
</div>
<div class="col-lg-3 col-xs-6">
<div class="icon">
<img src="/img/mswa/inline-packaging.svg"/>
</div>
<div class="title text-poppins">
<p>We use minimal packaging</p>
<p>{great for the planet}</p></div>
</div>
<div class="col-lg-3 col-xs-6">
<div class="icon">
<img src="/img/mswa/inline-quality.svg"/>
</div>
<div class="title text-poppins">
<p>We only choose quality</p>
<p>{better for your health}</p></div>
</div>
<div class="col-lg-3 col-xs-6">
<div class="icon">
<img src="/img/mswa/inline-community.svg"/>
</div>
<div class="title text-poppins">
<p>We love giving back</p>
<p>{great for our community}</p></div>
</div>
</div>
</div>
.did-you-know {
padding: 20px;
text-align: center;
}
.did-you-know .items .icon {
padding: 50px;
}
.did-you-know .items .title {
font-size: 20px;
}
here is a solution:
Replace images by your images.
<!DOCTYPE html>
<html>
<head>
<style>
* {
box-sizing: border-box;
}
.column {
float: left;
width: 25%;
padding: 5px;
}
/* Clearfix (clear floats) */
.row::after {
content: "";
clear: both;
display: table;
}
</style>
</head>
<body>
<div class="row">
<div class="column">
<img src="https://freesvg.org/img/cartoonsun.png" alt="Snow" style="width:100%">
<p style='text-align: center;'>test1</p>
</div>
<div class="column">
<img src="https://freesvg.org/img/cartoonsun.png" alt="Forest" style="width:100%">
<p style='text-align: center;'>test2</p>
</div>
<div class="column">
<img src="https://freesvg.org/img/cartoonsun.png" alt="Mountains" style="width:100%">
<p style='text-align: center;'>test3</p>
</div>
<div class="column">
<img src="https://freesvg.org/img/cartoonsun.png" alt="Mountains" style="width:100%">
<p style='text-align: center;'>test3</p>
</div>
</div>
</body>
</html>

Single column gallery with flexbox with certain divs split in two

I am making use of a gallery which represents a column containing either one or two <div> elements spanning across the entire width. The columns containing multiple <div> elements also contain images with different height and width properties. I would like these columns to be the same height and then fill the width as much as possible whenever there is extra space between them.
I would use a flexbox <div> element with a fixed width and a flex-wrap property. The <div> elements that are to span the entire width have a property max-width: 100%. A row with multiple items are inside a container <div> element which spans and then each in another box <div> element. I could get the two on the same lines, but since they vary in sizes I would not want each image to be 50% width, because then the empty space is above and below an item instead of between them.
I have tried tinkering with flex-grow, flex-shrink and flex-basis, however none of these seem ever to be exact. I also considered switching the <div> elements with two items to flex-direction: column and then wrap these. This however did not work for me.
.column {
width: 600px;
display: flex;
flex-wrap: wrap;
}
.smallContain {
min-width: 100%;
display: flex;
align-content: space-between;
}
.smallBox {
flex: 1 1 50%;
}
.largeBox {
min-width: 100%;
}
img {
max-width: 100%;
}
<body>
<div id="container">
<div class="column">
<div class="smallContain">
<div class="box smallBox">
<img src="#" class="imgS">
</div>
<div class="box smallBox">
<img src="#" class="imgS">
</div>
</div>
<div class="box largeBox">
<img src="#" class="imgL">
</div>
<div class="smallContain">
<div class="box smallBox">
<img src="#" class="imgS">
</div>
<div class="box smallBox">
<img src="#" class="imgS">
</div>
</div>
<div class="box largeBox">
<img src="#" class="imgL">
</div>
<div class="smallContain">
<div class="box smallBox">
<img src="#">
</div>
<div class="box smallBox">
<img src="#">
</div>
</div>
<div class="smallContain">
<div class="box smallBox">
<img src="#" class="imgS">
</div>
<div class="box smallBox">
<img src="#" class="imgS">
</div>
</div>
<div class="box largeBox">
<img src="#" class="imgL">
</div>
</div>
</div>
</body>
(Within the example above, the .imgS class refer to small images and .imgL class refer to large images)
Here's an example of what I'm hoping to get it to look like.
your question is a bit hard to understand, even so I gave it a try, maybe what your looking is something like this?
.grid {
align-items: stretch;
display: flex;
flex-direction: row;
flex-wrap: wrap;
justify-content: space-between;
width: 100%;
}
.grid .item {
max-height: 400px;
padding: 5px;
}
.grid .item.smallBox {
flex-basis: auto;
flex-grow: 1;
flex-shrink: 1;
}
.grid .item.smallBox img {
object-fit: cover;
object-position: center;
}
.grid .item.largeBox {
flex-basis: 100%;
flex-grow: 1;
flex-shrink: 1;
}
.grid .item img {
height: 100%;
width: 100%;
}
<div class="grid">
<div class="item smallBox">
<img src="http://placeholder.pics/svg/280x500" alt="">
</div>
<div class="item smallBox">
<img src="http://placeholder.pics/svg/280x500" alt="">
</div>
<div class="item largeBox">
<img src="http://placeholder.pics/svg/1920x500" alt="">
</div>
<div class="item smallBox">
<img src="http://placeholder.pics/svg/480x500" alt="">
</div>
<div class="item smallBox">
<img src="http://placeholder.pics/svg/250x500" alt="">
</div>
<div class="item largeBox">
<img src="http://placeholder.pics/svg/1440x500" alt="">
</div>
<div class="item smallBox">
<img src="http://placeholder.pics/svg/250x500" alt="">
</div>
<div class="item smallBox">
<img src="http://placeholder.pics/svg/480x500" alt="">
</div>
<div class="item largeBox">
<img src="http://placeholder.pics/svg/1440x500" alt="">
</div>
<div class="item smallBox">
<img src="http://placeholder.pics/svg/500x500" alt="">
</div>
<div class="item smallBox">
<img src="http://placeholder.pics/svg/150x500" alt="">
</div>
<div class="item largeBox">
<img src="http://placeholder.pics/svg/1440x500" alt="">
</div>
</div>
Hope it helps, good luck.

how to make sure that that grid layout row adjusts the height automatically as per content

*{
box-sizing: border-box;
}
.results__item{
float: left;
width: calc(100%/3 - 40px/3)
}
.results__item:nth-child(3n-1){
margin-left: 20px;
margin-right: 20px;
}
.results__item__img-wrapper{
overflow: hidden;
}
.results__item__img-wrapper img{
width: 100%;
height: calc(100%/3 - 40px/3 + 90px)
}
.results__item__content{
word-wrap: break-word;
}
<div class="results">
<div class="results__item">
<div class="results__item__img-wrapper">
<img src="https://cdn09.nnnow.com/web-images/medium/styles/071FYGE4ZRM/1473831055127/1.jpg" alt="">
</div>
<div class="results__item__content-wrapper">
<div class="title">Product1 Product1 Product1 Product1 Product1 Product1 Product1 Product1</div>
<div class="price">$122.00</div>
</div>
</div>
<div class="results__item">
<div class="results__item__img-wrapper">
<img src="https://cdn09.nnnow.com/web-images/medium/styles/071FYGE4ZRM/1473831055127/1.jpg" alt="">
</div>
<div class="results__item__content-wrapper">
<div class="title">Product2</div>
<div class="price">$122.00</div>
</div>
</div>
<div class="results__item">
<div class="results__item__img-wrapper">
<img src="https://cdn09.nnnow.com/web-images/medium/styles/071FYGE4ZRM/1473831055127/1.jpg" alt="">
</div>
<div class="results__item__content-wrapper">
<div class="title">Product2</div>
<div class="price">$122.00</div>
</div>
</div>
<div class="results__item">
<div class="results__item__img-wrapper">
<img src="https://cdn09.nnnow.com/web-images/medium/styles/071FYGE4ZRM/1473831055127/1.jpg" alt="">
</div>
<div class="results__item__content-wrapper">
<div class="title">Product2</div>
<div class="price">$122.00</div>
</div>
</div>
<div class="results__item">
<div class="results__item__img-wrapper">
<img src="https://cdn09.nnnow.com/web-images/medium/styles/071FYGE4ZRM/1473831055127/1.jpg" alt="">
</div>
<div class="results__item__content-wrapper">
<div class="title">Product2</div>
<div class="price">$122.00</div>
</div>
</div>
<div class="results__item">
<div class="results__item__img-wrapper">
<img src="https://cdn09.nnnow.com/web-images/medium/styles/071FYGE4ZRM/1473831055127/1.jpg" alt="">
</div>
<div class="results__item__content-wrapper">
<div class="title">Product2</div>
<div class="price">$122.00</div>
</div>
</div>
</div>
I have created a grid layout. When the content of one item is more, the height of the row is not adjusting accordingly. How can I accomplish that?
Note: I dont want to use javascript for this. I am sure, this is possible with CSS
http://jsbin.com/kopatojiho/1/edit?html,css,output
Wrap every three images with a container. This way, you will have them all stack correctly beside each other as you can see on this image:
Also make sure to clear the collapsing on each of the containers you'll add as well, as they are collapsed because of the floated images. I normally use overflow: auto for this, but check this SO post for more ways to do it.

CSS: Two pictures showing in one column

Would you help me please make appear pictures in one column? It needs to be full width with no space between those images.
Thanks in advance.
What I want it to look like
What I have
Code:
img,
.image {
display: block;
height: 350px;
margin: 0;
width: 50%;
}
<section class="main">
<div class="container">
<div class="full-width">
<div class="vibe_editor clearfix">
<div class="v_module v_column col-md-12 fullwidth v_first">
<style>
<div class="v_module v_text_block about_us">
<p>
<a href="http://www.kurzon.cz/wp-content/uploads/2015/10/homepage-o-nas.jpg?189db0">
<img class="alignnone size-big wp-image-3125" width="768" height="282" alt="o-nas1" src="http://www.kurzon.cz/wp-content/uploads/2015/10/homepage-o-nas-768x282.jpg?189db0">
</a>
<a href="http://www.kurzon.cz/wp-content/uploads/2015/10/2048x1536-orange-red-solid-color-background.jpg?189db0">
</p>
</div>
</div>
<div class="v_module v_column col-md-12 fullwidth v_first">
</div>
</div>
</div>
</section>
href="http://www.kurzon.cz/wp-content/uploads/2015/10/homepage-o-nas.jpg?189db0"> <img class="alignnone size-big wp-image-3125" width="768" height="282" alt="o-nas1" src="http://www.kurzon.cz/wp-content/uploads/2015/10/homepage-o-nas-768x282.jpg?189db0"> </a> <a href="http://www.kurzon.cz/wp-content/uploads/2015/10/2048x1536-orange-red-solid-color-background.jpg?189db0"> </p> </div> </div> <div class="v_module v_column col-md-12 fullwidth v_first"> </div> </div> </div> </section>
The p tag has padding by default remove it?
Also remove unwanted <style> tag

Bootstrap, layout only works at small screen sizes

I have a jsfiddle here - http://jsfiddle.net/7psczxog/5/
It's just two blocks that contain an image and some text in two separate divs.
At smaller sizes the image and text sit on top of each other.
Each block also has a triangle that should site in the middle at the bottom of the block.
My problem is the blocks only work at smaller sizes when the image is on top of the text.
At larger sizes the block has no background color and the triangle moves to the top.
<div class="container">
<div class="row">
<div class="testimonialBlock triangle-section clearfix block0">
<div class="col-sm-4">
<img src="http://placehold.it/350x150" alt="image" class="img-responsive"/>
</div>
<div class="col-sm-8">
<h4>Trader Testimonial 1</h4>
<h5>Trader Testimonial By 1</h5>
<p>Trader Testimonial Text 1</p>
</div>
</div><!--testimonialBlock-->
</div>
<div class="row">
<div class="testimonialBlock triangle-section clearfix block1">
<div class="col-sm-4">
<img src="http://placehold.it/350x150" alt="image" class="img-responsive"/>
</div>
<div class="col-sm-8">
<h4>Trader Testimonial 2</h4>
<h5>Trader Testimonial By 2</h5>
<p>Trader Testimonial Text 2</p>
</div>
</div><!--testimonialBlock-->
</div>
Is this what you are looking for?
http://jsfiddle.net/prsne4a7/
HTML:
<div class="container">
<div class="triangle-section-row row">
<div class="testimonialBlock triangle-section block0">
<div class="col-xs-4">
<img src="http://placehold.it/350x150" alt="image" class="img-responsive"/>
</div>
<div class="col-xs-8">
<h4>Trader Testimonial 1</h4>
<h5>Trader Testimonial By 1</h5>
<p>Trader Testimonial Text 1</p>
</div>
</div><!--testimonialBlock-->
</div>
<div class="triangle-section-row row">
<div class="testimonialBlock triangle-section block1">
<div class="col-xs-4">
<img src="http://placehold.it/350x150" alt="image" class="img-responsive"/>
</div>
<div class="col-xs-8">
<h4>Trader Testimonial 2</h4>
<h5>Trader Testimonial By 2</h5>
<p>Trader Testimonial Text 2</p>
</div>
</div><!--testimonialBlock-->
</div>
</div>
CSS:
.triangle-section-row{
background: red;
margin: 0 0 50px 0;
position: relative;
}
.triangle-section:after{
border-style: solid;
border-width: 20px 20px 0 20px;
border-color: red transparent transparent transparent;
bottom: -20px;
left: 50%;
content: "";
height: 0;
margin-left:-20px;
width: 0;
position: absolute;
}
I just bumped the position: relative to the parent of .triangle-section and used col-xs-* instead of col-sm-* to keep the columns consistent across all client widths. col-sm-* only enforces the columns when the client area width is greater than 768px.
See the Bootstrap grid documentation for more information about the responsive grid:
http://getbootstrap.com/css/#grid-options

Resources