I am a UI Designer. I want each image float to the left one beneath another. But its appearing like. http://delhiwebdesigner.com/images/Capture.png Please check where the problem is. Below is my HTML and CSS Codes:
<div class="books-container">
<article class="entry">
<img src="images/books/1.jpg" alt="" title="" />
<a href="#">
<div class="text">
<p class="head">LeMans</p>
<p class="title">LeMans</p>
</div>
</a>
</article>
<article class="entry">
<img src="images/books/2.jpg" alt="" title="" />
<a href="#">
<div class="text">
<p class="head">LeMans</p>
<p class="title">LeMans</p>
</div>
</a>
</article>
<article class="entry">
<img src="images/books/4.jpg" alt="" title="" />
<a href="#">
<div class="text">
<p class="head">LeMans</p>
<p class="title">LeMans</p>
</div>
</a>
</article>
<article class="entry">
<img src="images/books/3.jpg" alt="" title="" />
<a href="#">
<div class="text">
<p class="head">LeMans</p>
<p class="title">LeMans</p>
</div>
</a>
</article>
<article class="entry">
<img src="images/books/5.jpg" alt="" title="" />
<a href="#">
<div class="text">
<p class="head">LeMans</p>
<p class="title">LeMans</p>
</div>
</a>
</article>
<article class="entry">
<img src="images/books/6.jpg" alt="" title="" />
<a href="#">
<div class="text">
<p class="head">LeMans</p>
<p class="title">LeMans</p>
</div>
</a>
</article>
<article class="entry">
<img src="images/books/7.jpg" alt="" title="" />
<a href="#">
<div class="text">
<p class="head">LeMans</p>
<p class="title">LeMans</p>
</div>
</a>
</article>
<article class="entry">
<img src="images/books/8.jpg" alt="" title="" />
<a href="#">
<div class="text">
<p class="head">LeMans</p>
<p class="title">LeMans</p>
</div>
</a>
</article>
<article class="entry">
<img src="images/books/9.jpg" alt="" title="" />
<a href="#">
<div class="text">
<p class="head">LeMans</p>
<p class="title">LeMans</p>
</div>
</a>
</article>
<article class="entry">
<img src="images/books/10.jpg" alt="" title="" />
<a href="#">
<div class="text">
<p class="head">LeMans</p>
<p class="title">LeMans</p>
</div>
</a>
</article>
<article class="entry">
<img src="images/books/11.jpg" alt="" title="" />
<a href="#">
<div class="text">
<p class="head">LeMans</p>
<p class="title">LeMans</p>
</div>
</a>
</article>
<article class="entry">
<img src="images/books/12.jpg" alt="" title="" />
<a href="#">
<div class="text">
<p class="head">LeMans</p>
<p class="title">LeMans</p>
</div>
</a>
</article>
<article class="entry">
<img src="images/books/13.jpg" alt="" title="" />
<a href="#">
<div class="text">
<p class="head">LeMans</p>
<p class="title">LeMans</p>
</div>
</a>
</article>
<div class="clear"></div>
CSS code as folowed:-
.books-container {
width: 1200px;
margin: 100px auto 0;
}
.entry {
width: 25%;
float: left;
height: auto;
padding: 10px;
position: relative;
}
.entry img {
width: 100%;
display: block;
}
.entry .text {
position: absolute;
display: none;
top: 0;
vertical-align: middle;
height: 100%;
background: red;
opacity: 0.5;
text-align: center;
width: 100%;
padding: 10px;
}
http://jsfiddle.net/6deqxyk4/4/
.books-container {max-width: 1200px;width:100%; margin: 100px auto 0;}
.entry {width:400px; float: left; height: auto; padding: 10px; position: relative;}
.entry img {width: 100%; display: block;}
.entry .text {position: absolute; display: none; top: 0; vertical-align: middle; height: 100%; background: red; opacity: 0.5; text-align: center; width: 100%; padding: 10px;}
Related
I started learning web programming and i want to test some features but there is a problem, when I bring the mouse on the above photos, the bottom ones change place like in the photo. The photos below are on the left in the first opening, while hovering on the top one, it shifts to the right.
Like this:
*{
box-sizing: border-box;
}
#gallery{
width: 1200px;
margin: 20px auto;
}
.item-container{
width: 25%;
float: left;
padding: 10px;
}
.gallery-item{
border: 1px solid #ccc;
transition: border 0.4s linear;
}
.gallery-item:hover{
border: 3px solid #777;
cursor: pointer;
}
.gallery-item img{
width: 100%;
height: 200px;
object-fit: contain;
background-color: #DCDCDC;
}
.description{
text-align: center;
padding: 15px;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Art Gallery</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div id="gallery">
<div class="item-container">
<div class="gallery-item">
<a href="img/1.jpg" target="_blank">
<img src="img/1.jpg" alt="" >
</a>
<div class="description">
description about image gallery item
</div>
</div>
</div>
</div>
<div id="gallery">
<div class="item-container">
<div class="gallery-item">
<a href="img/2.jpg" target="_blank">
<img src="img/2.jpg" alt="" >
</a>
<div class="description">
description about image gallery item
</div>
</div>
</div>
</div>
<div id="gallery">
<div class="item-container">
<div class="gallery-item">
<a href="img/3.jpg" target="_blank">
<img src="img/3.jpg" alt="" >
</a>
<div class="description">
description about image gallery item
</div>
</div>
</div>
</div>
<div id="gallery">
<div class="item-container">
<div class="gallery-item">
<a href="img/4.jpg" target="_blank">
<img src="img/4.jpg" alt="" >
</a>
<div class="description">
description about image gallery item
</div>
</div>
</div>
</div>
<div id="gallery">
<div class="item-container">
<div class="gallery-item">
<a href="img/5.jpg" target="_blank">
<img src="img/5.jpg" alt="" >
</a>
<div class="description">
description about image gallery item
</div>
</div>
</div>
</div>
<div id="gallery">
<div class="item-container">
<div class="gallery-item">
<a href="img/6.jpg" target="_blank">
<img src="img/6.jpg" alt="" >
</a>
<div class="description">
description about image gallery item
</div>
</div>
</div>
</div>
</body>
</html>
How can i fix it?
Updated answer
Add outline instant of border
The problem with your border hover css
From
.gallery-item:hover{
border: 3px solid #777;
cursor: pointer;
}
To
.gallery-item:hover{
border: 1px solid #777;
cursor: pointer;
}
*{
box-sizing: border-box;
}
#gallery{
width: 1200px;
margin: 20px auto;
}
.item-container{
width: 25%;
float: left;
padding: 10px;
}
.gallery-item{
outline: 1px solid #ccc;
transition: border 0.4s linear;
}
.gallery-item:hover{
outline: 3px solid #777;
cursor: pointer;
}
.gallery-item img{
width: 100%;
height: 200px;
object-fit: contain;
background-color: #DCDCDC;
}
.description{
text-align: center;
padding: 15px;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Art Gallery</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div id="gallery">
<div class="item-container">
<div class="gallery-item">
<a href="img/1.jpg" target="_blank">
<img src="img/1.jpg" alt="" >
</a>
<div class="description">
description about image gallery item
</div>
</div>
</div>
</div>
<div id="gallery">
<div class="item-container">
<div class="gallery-item">
<a href="img/2.jpg" target="_blank">
<img src="img/2.jpg" alt="" >
</a>
<div class="description">
description about image gallery item
</div>
</div>
</div>
</div>
<div id="gallery">
<div class="item-container">
<div class="gallery-item">
<a href="img/3.jpg" target="_blank">
<img src="img/3.jpg" alt="" >
</a>
<div class="description">
description about image gallery item
</div>
</div>
</div>
</div>
<div id="gallery">
<div class="item-container">
<div class="gallery-item">
<a href="img/4.jpg" target="_blank">
<img src="img/4.jpg" alt="" >
</a>
<div class="description">
description about image gallery item
</div>
</div>
</div>
</div>
<div id="gallery">
<div class="item-container">
<div class="gallery-item">
<a href="img/5.jpg" target="_blank">
<img src="img/5.jpg" alt="" >
</a>
<div class="description">
description about image gallery item
</div>
</div>
</div>
</div>
<div id="gallery">
<div class="item-container">
<div class="gallery-item">
<a href="img/6.jpg" target="_blank">
<img src="img/6.jpg" alt="" >
</a>
<div class="description">
description about image gallery item
</div>
</div>
</div>
</div>
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 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'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>
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