I'm sure this is obvious but I can't figure it out. I want to create a grid of images like so:
[Image] [Image] | [ Big
[Image] [Image] | Image ]
I can do this fine with just images but the problem is that the images are nested inside links. So I'm trying to figure out how to make the links float left.
My HTML is:
<div class="row">
<div class="col-md-6">
<a href="img/1-1full.png" title="" data-gallery>
<img src="img/1-1.png" alt="">
</a>
<a href="img/1-2full.png" title="" data-gallery>
<img src="img/1-2.png" alt="">
</a>
<a href="img/1-3full.png" title="" data-gallery>
<img src="img/1-3.png" alt="">
</a>
<a href="img/1-4full.png" title="" data-gallery>
<img src="img/1-4.png" alt="">
</a>
</div>
<div class="col-md-6">
<a href="img/1-largefull.png" title="" data-gallery>
<img src="img/1-large.png" alt="">
</a>
</div>
</div>
<div style="clear: both;">
My CSS is:
.gallery .col-md-6 a {
float: left;
display: block;
}
.gallery .col-md-6 a:nth-child(odd) {
width: 307px;
margin: 0 30px 30px 0;
}
.gallery .col-md-6 a:nth-child(even) {
width: 278px;
margin: 0;
}
The width of each col-md-6 is 585 px so they should fit together. .gallery is getting targeted correctly too, it's showing up in the code inspector. There's obviously something basic about floats that I'm not understanding.
If you're already using a grid framework (Bootstrap), why not take advantage of it. It's a little extra markup, but I think it achieves what you are looking for.
<div class="row">
<div class="col-md-6">
<div class="row">
<div class="col-md-6">
<a href="img/1-1full.png" title="" data-gallery>
<img src="img/1-1.png" alt="" class="img-responsive">
</a>
</div>
<div class="col-md-6">
<a href="img/1-2full.png" title="" data-gallery>
<img src="img/1-2.png" alt="" class="img-responsive">
</a>
</div>
</div>
<div class="row">
<div class="col-md-6">
<a href="img/1-3full.png" title="" data-gallery>
<img src="img/1-3.png" alt="" class="img-responsive">
</a>
</div>
<div class="col-md-6">
<a href="img/1-4full.png" title="" data-gallery>
<img src="img/1-4.png" alt="" class="img-responsive">
</a>
</div>
</div>
</div>
<div class="col-md-6">
<a href="img/1-largefull.png" title="" data-gallery>
<img src="img/1-large.png" alt="" class="img-responsive">
</a>
</div>
</div>
Would this work for you? I have given two examples, seeing your layout. One with 4 a row and the other with 2 a row.
* {box-sizing: border-box;}
.half {width: 50%;}
.quat {width: 25%;}
.sz34 {width: 75%;}
.cols {float: left;}
img {width: 100%; height: 65px; display: block; border: 1px solid #ccc;}
.parent {overflow: hidden;}
.parent div {float: left;}
img.double-height {height: 130px;}
<div class="parent">
<div class="half">
<div class="quat"><img src="" alt="Image"></div>
<div class="quat"><img src="" alt="Image"></div>
<div class="quat"><img src="" alt="Image"></div>
<div class="quat"><img src="" alt="Image"></div>
<div class="quat"><img src="" alt="Image"></div>
<div class="quat"><img src="" alt="Image"></div>
<div class="quat"><img src="" alt="Image"></div>
<div class="quat"><img src="" alt="Image"></div>
</div>
<div class="half">
<img src="" alt="Image" class="double-height">
</div>
</div>
<hr />
<div class="parent">
<div class="half">
<div class="half"><img src="" alt="Image"></div>
<div class="half"><img src="" alt="Image"></div>
<div class="half"><img src="" alt="Image"></div>
<div class="half"><img src="" alt="Image"></div>
</div>
<div class="half">
<img src="" alt="Image" class="double-height">
</div>
</div>
Related
I have 8 pictures which I want to place into 2 rows of 4 pictures each using flex-box. How would I do this? I've tried using flex-wrap but that made it so on the first row there were 5 images and on the second 3 images.
<div class="images">
<a href="" class="img1">
<img src="images/ballon.jpg" alt="">
<h4></h4>
</a>
<a href="" class="img2">
<img src="images/planche.jpg" alt="">
</a>
<a href="" class="img3">
<img src="images/golf.jpg" alt="">
</a>
<a href="" class="img4">
<img src="images/casque.jpg" alt="">
</a>
<a href="" class="img5">
<img src="images/patin.jpg" alt="">
</a>
<a href="" class="img6">
<img src="images/velo.jpg" alt="">
</a>
<a href="" class="img7">
<img src="images/yoga.jpg" alt="">
</a>
<a href="" class="img8">
<img src="images/genoux.jpg" alt="">
</a>
voir plus
</div>
div.images{
display: flex;
}
div.images img{
width: 200px;
height: 200px;
}
Set the parent div to have flex-flow: column , and the wrap each group of 4 images in a div and the set this div to have display: flex.
Hence, my solution would be:
<div class="images">
<div class="row">
<a href="" class="img">
<img src="http://placekitten.com/200/200" alt="">
<h4></h4>
</a>
<a href="" class="img">
<img src="http://placekitten.com/200/200" alt="">
<h4></h4>
</a>
<a href="" class="img">
<img src="http://placekitten.com/200/200" alt="">
<h4></h4>
</a>
<a href="" class="img">
<img src="http://placekitten.com/200/200" alt="">
<h4></h4>
</a>
</div>
<div class="row">
<a href="" class="img">
<img src="http://placekitten.com/200/200" alt="">
<h4></h4>
</a>
<a href="" class="img">
<img src="http://placekitten.com/200/200" alt="">
<h4></h4>
</a>
<a href="" class="img">
<img src="http://placekitten.com/200/200" alt="">
<h4></h4>
</a>
<a href="" class="img">
<img src="http://placekitten.com/200/200" alt="">
<h4></h4>
</a>
</div>
<div class="row">
voir plus
</div>
</div>
<style>
div.images{
display: flex;
flex-flow: column;
}
div.images div.row {
display: flex;
flex-flow: row;
}
div.images img{
width: 200px;
height: 200px;
}
</style>
i want to show products like different gird. i think i don't know what my question but i am showing product like this image:
i tried to bootstrap but no response.
my code is :
<div class="col-md-2 column productbox">
<img src="http://placehold.it/460x250/e67e22/ffffff&text=HTML5" class="img-responsive">
<div class="producttitle">Product 2</div>
<div class="productprice">
<div class="pull-right">BUY</div>
<div class="pricetext">£8.95</div>
</div>
</div>
<div class="col-md-2 column productbox">
<img src="http://placehold.it/460x250/e67e22/ffffff&text=HTML5" class="img-responsive">
<div class="producttitle">Product 2</div>
<div class="productprice">
<div class="pull-right">BUY</div>
<div class="pricetext">£8.95</div>
</div>
</div>
<div class="col-md-2 column productbox">
<img src="http://placehold.it/460x250/e67e22/ffffff&text=HTML5" class="img-responsive">
<div class="producttitle">Product 3</div>
<div class="productprice">
<div class="pull-right">BUY</div>
<div class="pricetext">£8.95</div>
</div>
</div>
<div class="col-md-2 column productbox">
<img src="http://placehold.it/460x250/e67e22/ffffff&text=HTML5" class="img-responsive">
<div class="producttitle">Product 4</div>
<div class="productprice">
<div class="pull-right">BUY</div>
<div class="pricetext"> £8.95</div>
</div>
</div>
anybody can help me?
thanks
You can achieve this using CSS3 Flexbox property. Here
is the link.
* {box-sizing: border-box}
body {margin: 0}
.row {
display: flex;
flex-wrap: wrap;
padding: 0 4px;
}
/* Create four equal columns that sits next to each other */
.column {
flex: 25%;
max-width: 25%;
padding: 0 4px;
}
.column img {
display: block;
width: 100%;
margin-top: 8px;
}
/* Responsive layout - makes a two column-layout instead of four columns */
#media (max-width: 800px) {
.column {
flex: 50%;
max-width: 50%;
}
}
/* Responsive layout - makes the two columns stack on top of each other instead of next to each other */
#media (max-width: 600px) {
.column {
flex: 100%;
max-width: 100%;
}
}
<div class="row">
<div class="column">
<img src="https://www.w3schools.com/w3images/wedding.jpg" alt="">
<img src="https://www.w3schools.com/w3images/rocks.jpg" alt="">
<img src="https://www.w3schools.com/w3images/falls2.jpg" alt="">
<img src="https://www.w3schools.com/w3images/paris.jpg" alt="">
<img src="https://www.w3schools.com/w3images/nature.jpg" alt="">
<img src="https://www.w3schools.com/w3images/mist.jpg" alt="">
<img src="https://www.w3schools.com/w3images/paris.jpg" alt="">
</div>
<div class="column">
<img src="https://www.w3schools.com/w3images/underwater.jpg" alt="">
<img src="https://www.w3schools.com/w3images/ocean.jpg" alt="">
<img src="https://www.w3schools.com/w3images/wedding.jpg" alt="">
<img src="https://www.w3schools.com/w3images/mountainskies.jpg" alt="">
<img src="https://www.w3schools.com/w3images/rocks.jpg" alt="">
<img src="https://www.w3schools.com/w3images/underwater.jpg" alt="">
</div>
<div class="column">
<img src="https://www.w3schools.com/w3images/wedding.jpg" alt="">
<img src="https://www.w3schools.com/w3images/rocks.jpg" alt="">
<img src="https://www.w3schools.com/w3images/falls2.jpg" alt="">
<img src="https://www.w3schools.com/w3images/paris.jpg" alt="">
<img src="https://www.w3schools.com/w3images/nature.jpg" alt="">
<img src="https://www.w3schools.com/w3images/mist.jpg" alt="">
<img src="https://www.w3schools.com/w3images/paris.jpg" alt="">
</div>
<div class="column">
<img src="https://www.w3schools.com/w3images/underwater.jpg" alt="">
<img src="https://www.w3schools.com/w3images/ocean.jpg" alt="">
<img src="https://www.w3schools.com/w3images/wedding.jpg" alt="">
<img src="https://www.w3schools.com/w3images/mountainskies.jpg" alt="">
<img src="https://www.w3schools.com/w3images/rocks.jpg" alt="">
<img src="https://www.w3schools.com/w3images/underwater.jpg" alt="">
</div>
</div>
I am playing around with Bootstrap and I ran into a small problem that I can't find a solution for. There probably is a solution out there, but I can't, for the life of me, figure out what to search for.
What I want to know is, if there is a way to make the columns snap to each other, so a big gap doesn't show up like shown in the fiddle, below the first div on the left hand side. I hope the fiddle describes the problem well enough for someone to point me in the right direction.
Fiddle: https://jsfiddle.net/DTcHh/24238/
body {
background: tomato;
}
.container {
background: white;
border: 1px solid grey;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />
<div class="row">
<div class="col-md-6 container">
<h3>Title</h3>
<p>Paragraph</p>
<div class="media-container">
<a href="http://placehold.it/200x200">
<img src="http://placehold.it/200x200" />
</a>
<a href="http://placehold.it/200x200">
<img src="http://placehold.it/200x200" />
</a>
<a href="http://placehold.it/200x200">
<img src="http://placehold.it/200x200" />
</a>
<a href="http://placehold.it/200x200">
<img src="http://placehold.it/200x200" />
</a>
<a href="http://placehold.it/200x200">
<img src="http://placehold.it/200x200" />
</a>
</div>
</div>
<div class="col-md-6 container">
<h3>Title</h3>
<p>Paragraph</p>
<div class="media-container">
<a href="http://placehold.it/200x200">
<img src="http://placehold.it/200x200" />
</a>
<a href="http://placehold.it/200x200">
<img src="http://placehold.it/200x200" />
</a>
<a href="http://placehold.it/200x200">
<img src="http://placehold.it/200x200" />
</a>
</div>
</div>
<div class="col-md-6 container">
<h3>Title</h3>
<p>Paragraph</p>
<div class="media-container">
<a href="http://placehold.it/200x200">
<img src="http://placehold.it/200x200" />
</a>
<a href="http://placehold.it/200x200">
<img src="http://placehold.it/200x200" />
</a>
<a href="http://placehold.it/200x200">
<img src="http://placehold.it/200x200" />
</a>
</div>
</div>
<div class="col-md-6 container">
<h3>Title</h3>
<p>Paragraph</p>
<div class="media-container">
<a href="http://placehold.it/200x200">
<img src="http://placehold.it/200x200" />
</a>
<a href="http://placehold.it/200x200">
<img src="http://placehold.it/200x200" />
</a>
<a href="http://placehold.it/200x200">
<img src="http://placehold.it/200x200" />
</a>
</div>
</div>
<div class="col-md-6 container">
<h3>Title</h3>
<p>Paragraph</p>
<div class="media-container">
<a href="http://placehold.it/200x200">
<img src="http://placehold.it/200x200" />
</a>
<a href="http://placehold.it/200x200">
<img src="http://placehold.it/200x200" />
</a>
<a href="http://placehold.it/200x200">
<img src="http://placehold.it/200x200" />
</a>
</div>
</div>
<div class="col-md-6 container">
<h3>Title</h3>
<p>Paragraph</p>
<div class="media-container">
<a href="http://placehold.it/200x200" />
<img src="http://placehold.it/200x200" />
</a>
<a href="http://placehold.it/200x200" />
<img src="http://placehold.it/200x200" />
</a>
<a href="http://placehold.it/200x200" />
<img src="http://placehold.it/200x200" />
</a>
</div>
</div>
</div>
Problem in your bootstrap grid structure. You use "container" class under "ROW" & "COL-MD-" so that's why you face the problem.
Working fiddle: https://jsfiddle.net/amitmonsterme/veyq6naL/
view this tutorial : http://getbootstrap.com/css/#overview-container
You can apply the float: right property to particular blocks when the screen width becomes 992px or more. I've defined a new special class .pull-md-right for this purpose.
Please check the result: https://jsfiddle.net/glebkema/9dqsj4pk/
#import url('https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css');
body {
background: tomato;
}
.container {
background: white;
border: 1px solid grey;
}
#media (min-width: 992px) {
.pull-md-right {
float: right !important;
}
}
<div class="container">
<div class="row">
<div class="col-md-6">
<h3>Title 1</h3>
<p>Paragraph</p>
<div class="media-container">
<img src="http://placehold.it/200x200">
<img src="http://placehold.it/200x200">
<img src="http://placehold.it/200x200">
<img src="http://placehold.it/200x200">
<img src="http://placehold.it/200x200">
</div>
</div>
<div class="col-md-6">
<h3>Title 2</h3>
<p>Paragraph</p>
<div class="media-container">
<img src="http://placehold.it/200x200">
<img src="http://placehold.it/200x200">
<img src="http://placehold.it/200x200">
</div>
</div>
<div class="col-md-6 pull-md-right">
<h3>Title 3</h3>
<p>Paragraph</p>
<div class="media-container">
<img src="http://placehold.it/200x200">
<img src="http://placehold.it/200x200">
<img src="http://placehold.it/200x200">
</div>
</div>
<div class="col-md-6">
<h3>Title 4</h3>
<p>Paragraph</p>
<div class="media-container">
<img src="http://placehold.it/200x200">
<img src="http://placehold.it/200x200">
<img src="http://placehold.it/200x200">
</div>
</div>
<div class="col-md-6 pull-md-right">
<h3>Title 5</h3>
<p>Paragraph</p>
<div class="media-container">
<img src="http://placehold.it/200x200">
<img src="http://placehold.it/200x200">
<img src="http://placehold.it/200x200">
</div>
</div>
<div class="col-md-6">
<h3>Title 6</h3>
<p>Paragraph</p>
<div class="media-container">
<img src="http://placehold.it/200x200">
<img src="http://placehold.it/200x200">
<img src="http://placehold.it/200x200">
</div>
</div>
</div>
</div>
I created a Bootstrap Thumbnail image grid originally and the HR would instantly jump below all of the images.
I decided to delete the Bootstrap image grid and change it to a Lightbox image grid which is so much better.
I've not got a problem that the HR which should be acting as a Footer HR, is now ignoring all of the pictures and is jumping straight back up to the top of the page.
Is this something to do with the pre-set CSS configuration within Lightbox?
HTML:
<div class="container lightbox">
<div class="gallery">
<div class="row row1">
<div class="col-md-3">
<a href="Pictures/Pic1.jpg" data-title="Picture #1" data-lightbox="Picture Number 1">
<img src="Pictures/Pic1.jpg" width="200px" class="img-thumbnail">
</a>
</div>
<div class="col-md-3">
<a href="Pictures/Pic6.jpg" data-title="Picture #2" data-lightbox="Picture Number 2">
<img src="Pictures/Pic6.jpg" width="200px" class="img-thumbnail">
</a>
</div>
<div class="col-md-3">
<a href="Pictures/Pic7.jpg" data-title="Picture #3" data-lightbox="Picture Number 3">
<img src="Pictures/Pic7.jpg" width="200px" class="img-thumbnail">
</a>
</div>
</div>
<div class="row row2">
<div class="col-md-3">
<a href="Pictures/Pic4.jpg" data-title="Picture #4" data-lightbox="Picture Number 4">
<img src="Pictures/Pic4.jpg" width="200px" class="img-thumbnail">
</a>
</div>
<div class="col-md-3">
<a href="Pictures/Pic5.jpg" data-title="Picture #5" data-lightbox="Picture Number 5">
<img src="Pictures/Pic5.jpg" width="200px" class="img-thumbnail">
</a>
</div>
<div class="col-md-3">
<a href="Pictures/Pic2.jpg" data-title="Picture #6" data-lightbox="Picture Number 6">
<img src="Pictures/Pic2.jpg" width="200px" class="img-thumbnail">
</a>
</div>
</div>
<div class="row row3">
<div class="col-md-3">
<a href="Pictures/Pic3.jpg" data-title="Picture #7" data-lightbox="Picture Number 7">
<img src="Pictures/Pic3.jpg" width="200px" class="img-thumbnail">
</a>
</div>
<div class="col-md-3">
<a href="Pictures/Pic8.jpg" data-title="Picture #8" data-lightbox="Picture Number 8">
<img src="Pictures/Pic8.jpg" width="200px" class="img-thumbnail">
</a>
</div>
<div class="col-md-3">
<a href="Pictures/Pic9.jpg" data-title="Picture #9" data-lightbox="Picture Number 9">
<img src="Pictures/Pic9.jpg" width="200px" class="img-thumbnail">
</a>
</div>
</div>
</div>
</div>
<hr class="bigHR2">
Very basic custom CSS :
.bigHR1 {
background-color: white !important;
color: white !important;
border: 2px solid white !important;
border-radius: 50%;
height: 1px !important;
width: 850px !important;
margin-left: 5%;
margin-top: -1%;
}
.row1 {
margin-top: 50%;
}
.row2 {
margin-top: 10%;
}
.row3 {
margin-top: 10%;
}
Both Bootstrap and Lightbox are installed LOCALLY, and am having no problem with Bootstrap on other pages of this website, so it must be the Lightbox.
I have a image gallery which is not straighting/fullfilling the full width in a row
html
<div class="col-md-6">
<figure class="gallery">
<img src="images/blog_1.png" alt="img">
<img src="images/blog_1.png" alt="img">
<img src="images/blog_1.png" alt="img">
<img src="images/blog_1.png" alt="img">
<img src="images/blog_1.png" alt="img">
<img src="images/blog_1.png" alt="img">
</figure>
</div>
css
.gallery{
display:table;
}
.gallery img{
display: inline-block;
padding: 2px;
background: transparent;
}
display:table-cell is also not working . There is 6 images here
.gallery{
display:table;
white-space: nowrap;
}
.gallery img{
display: inline-block;
padding: 2px;
background: transparent;
}
<div class="col-md-6">
<figure class="gallery">
<img src="http://placehold.it/100x100" alt="img" />
<img src="http://placehold.it/100x100" alt="img" />
<img src="http://placehold.it/100x100" alt="img" />
<img src="http://placehold.it/100x100" alt="img" />
<img src="http://placehold.it/100x100" alt="img" />
<img src="http://placehold.it/100x100" alt="img" />
</figure>
</div>
From what I understood (since you have not mentioned the image size.)
.gallery{
}
.gallery > div{
padding:2px;
}
.gallery img{
background: transparent;
width:100%;
}
<script src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>
<link href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<div class="col-md-12">
<div class="gallery row">
<div class="col-xs-2">
<img src="http://www.jpl.nasa.gov/spaceimages/images/mediumsize/PIA17011_ip.jpg" alt="img"/>
</div>
<div class="col-xs-2">
<img src="http://www.jpl.nasa.gov/spaceimages/images/mediumsize/PIA17011_ip.jpg" alt="img"/>
</div>
<div class="col-xs-2">
<img src="http://www.jpl.nasa.gov/spaceimages/images/mediumsize/PIA17011_ip.jpg" alt="img"/>
</div>
<div class="col-xs-2">
<img src="http://www.jpl.nasa.gov/spaceimages/images/mediumsize/PIA17011_ip.jpg" alt="img"/>
</div>
<div class="col-xs-2">
<img src="http://www.jpl.nasa.gov/spaceimages/images/mediumsize/PIA17011_ip.jpg" alt="img"/>
</div>
<div class="col-xs-2">
<img src="http://www.jpl.nasa.gov/spaceimages/images/mediumsize/PIA17011_ip.jpg" alt="img"/>
</div>
</div>
</div>
Add Below css
.gallery{
display:table;
margin:0;
}
DEMO