Html photo gallery - remove space

Multi tool use
up vote
0
down vote
favorite
I have a photo gallery in HTML / CSS and I have a space between 2 photos. I want the space to be like in photo (in left)
.portfolio-img {
width: 45%;
height: 100%;
margin-top: 2rem;
margin-left: 1rem;
}
<div class="container">
<div class="row">
<img src="images/img3.jpg" class="portfolio-img">
<img src="images/img1.jpg" class="portfolio-img">
<img src="images/img2.jpg" class="portfolio-img">
<img src="images/img4.jpg" class="portfolio-img">
</div>
</div>
html css image gallery responsive
add a comment |
up vote
0
down vote
favorite
I have a photo gallery in HTML / CSS and I have a space between 2 photos. I want the space to be like in photo (in left)
.portfolio-img {
width: 45%;
height: 100%;
margin-top: 2rem;
margin-left: 1rem;
}
<div class="container">
<div class="row">
<img src="images/img3.jpg" class="portfolio-img">
<img src="images/img1.jpg" class="portfolio-img">
<img src="images/img2.jpg" class="portfolio-img">
<img src="images/img4.jpg" class="portfolio-img">
</div>
</div>
html css image gallery responsive
it is not clear what you want - perhaps you mean something like masonry.desandro.com
– mplungjan
7 hours ago
Please edit the snippet I made and add images from lorempixel.com or similar
– mplungjan
7 hours ago
Have a look at codepen.io/jensimmons/pen/XdBxav
– George
7 hours ago
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I have a photo gallery in HTML / CSS and I have a space between 2 photos. I want the space to be like in photo (in left)
.portfolio-img {
width: 45%;
height: 100%;
margin-top: 2rem;
margin-left: 1rem;
}
<div class="container">
<div class="row">
<img src="images/img3.jpg" class="portfolio-img">
<img src="images/img1.jpg" class="portfolio-img">
<img src="images/img2.jpg" class="portfolio-img">
<img src="images/img4.jpg" class="portfolio-img">
</div>
</div>
html css image gallery responsive
I have a photo gallery in HTML / CSS and I have a space between 2 photos. I want the space to be like in photo (in left)
.portfolio-img {
width: 45%;
height: 100%;
margin-top: 2rem;
margin-left: 1rem;
}
<div class="container">
<div class="row">
<img src="images/img3.jpg" class="portfolio-img">
<img src="images/img1.jpg" class="portfolio-img">
<img src="images/img2.jpg" class="portfolio-img">
<img src="images/img4.jpg" class="portfolio-img">
</div>
</div>
.portfolio-img {
width: 45%;
height: 100%;
margin-top: 2rem;
margin-left: 1rem;
}
<div class="container">
<div class="row">
<img src="images/img3.jpg" class="portfolio-img">
<img src="images/img1.jpg" class="portfolio-img">
<img src="images/img2.jpg" class="portfolio-img">
<img src="images/img4.jpg" class="portfolio-img">
</div>
</div>
.portfolio-img {
width: 45%;
height: 100%;
margin-top: 2rem;
margin-left: 1rem;
}
<div class="container">
<div class="row">
<img src="images/img3.jpg" class="portfolio-img">
<img src="images/img1.jpg" class="portfolio-img">
<img src="images/img2.jpg" class="portfolio-img">
<img src="images/img4.jpg" class="portfolio-img">
</div>
</div>
html css image gallery responsive
html css image gallery responsive
edited 7 hours ago
mplungjan
85.4k20120180
85.4k20120180
asked 7 hours ago


Ciuca Cristi
11
11
it is not clear what you want - perhaps you mean something like masonry.desandro.com
– mplungjan
7 hours ago
Please edit the snippet I made and add images from lorempixel.com or similar
– mplungjan
7 hours ago
Have a look at codepen.io/jensimmons/pen/XdBxav
– George
7 hours ago
add a comment |
it is not clear what you want - perhaps you mean something like masonry.desandro.com
– mplungjan
7 hours ago
Please edit the snippet I made and add images from lorempixel.com or similar
– mplungjan
7 hours ago
Have a look at codepen.io/jensimmons/pen/XdBxav
– George
7 hours ago
it is not clear what you want - perhaps you mean something like masonry.desandro.com
– mplungjan
7 hours ago
it is not clear what you want - perhaps you mean something like masonry.desandro.com
– mplungjan
7 hours ago
Please edit the snippet I made and add images from lorempixel.com or similar
– mplungjan
7 hours ago
Please edit the snippet I made and add images from lorempixel.com or similar
– mplungjan
7 hours ago
Have a look at codepen.io/jensimmons/pen/XdBxav
– George
7 hours ago
Have a look at codepen.io/jensimmons/pen/XdBxav
– George
7 hours ago
add a comment |
5 Answers
5
active
oldest
votes
up vote
0
down vote
You can use
.porfolio-img {
width: 45%;
height: 100%;
background-size: cover;
background-repeat: no-repeat;
background-position: center;
}
background-size: cover
will ensure that the source image covers the area of the img
tag.
add a comment |
up vote
0
down vote
You are giving height in %
please change it to px
.portfolio-img {
width: 45%;
height: 300px; /* ---> give height it as you want */
margin-top: 2rem;
margin-left: 1rem;
}
<div class="container">
<div class="row">
<img src="images/img3.jpg" class="portfolio-img">
<img src="images/img1.jpg" class="portfolio-img">
<img src="images/img2.jpg" class="portfolio-img">
<img src="images/img4.jpg" class="portfolio-img">
</div>
</div>
New contributor
mohxn ayaz is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |
up vote
0
down vote
I want something like that:
image
codepen.io/anon/pen/RqoxEJ
– Ciuca Cristi
5 hours ago
add a comment |
up vote
0
down vote
There is a nice example in w3school website
https://www.w3schools.com/css/tryit.asp?filename=trycss3_flexbox_image_gallery
In summary you use display flex and divide the images into columns
This is the result for your case
.container {
display: flex;
flex-wrap: wrap;
}
.row {
flex: 50%;
max-width: 50%;
}
.portfolio-img {
width:100%;
vertical-align: middle;
}
<div class="container">
<div class="row">
<img src="https://images.pexels.com/photos/1089562/pexels-photo-1089562.jpeg?auto=compress&cs=tinysrgb&h=750&w=1260" class="portfolio-img filter development">
<img src="https://images.pexels.com/photos/1037996/pexels-photo-1037996.jpeg?auto=compress&cs=tinysrgb&h=750&w=1260" class="portfolio-img filter marketing">
</div>
<div class="row">
<img src="https://images.pexels.com/photos/1037995/pexels-photo-1037995.jpeg?auto=compress&cs=tinysrgb&h=750&w=1260" class="portfolio-img filter development">
<img src="https://images.pexels.com/photos/1037999/pexels-photo-1037999.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=750&w=1260" class="portfolio-img filter design">
</div>
</div>
add a comment |
up vote
0
down vote
I succeeded with this codepen.io/ms_yogi/pen/zpEXba. Thank you all!
add a comment |
5 Answers
5
active
oldest
votes
5 Answers
5
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
You can use
.porfolio-img {
width: 45%;
height: 100%;
background-size: cover;
background-repeat: no-repeat;
background-position: center;
}
background-size: cover
will ensure that the source image covers the area of the img
tag.
add a comment |
up vote
0
down vote
You can use
.porfolio-img {
width: 45%;
height: 100%;
background-size: cover;
background-repeat: no-repeat;
background-position: center;
}
background-size: cover
will ensure that the source image covers the area of the img
tag.
add a comment |
up vote
0
down vote
up vote
0
down vote
You can use
.porfolio-img {
width: 45%;
height: 100%;
background-size: cover;
background-repeat: no-repeat;
background-position: center;
}
background-size: cover
will ensure that the source image covers the area of the img
tag.
You can use
.porfolio-img {
width: 45%;
height: 100%;
background-size: cover;
background-repeat: no-repeat;
background-position: center;
}
background-size: cover
will ensure that the source image covers the area of the img
tag.
answered 7 hours ago
Riley Steele Parsons
1013
1013
add a comment |
add a comment |
up vote
0
down vote
You are giving height in %
please change it to px
.portfolio-img {
width: 45%;
height: 300px; /* ---> give height it as you want */
margin-top: 2rem;
margin-left: 1rem;
}
<div class="container">
<div class="row">
<img src="images/img3.jpg" class="portfolio-img">
<img src="images/img1.jpg" class="portfolio-img">
<img src="images/img2.jpg" class="portfolio-img">
<img src="images/img4.jpg" class="portfolio-img">
</div>
</div>
New contributor
mohxn ayaz is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |
up vote
0
down vote
You are giving height in %
please change it to px
.portfolio-img {
width: 45%;
height: 300px; /* ---> give height it as you want */
margin-top: 2rem;
margin-left: 1rem;
}
<div class="container">
<div class="row">
<img src="images/img3.jpg" class="portfolio-img">
<img src="images/img1.jpg" class="portfolio-img">
<img src="images/img2.jpg" class="portfolio-img">
<img src="images/img4.jpg" class="portfolio-img">
</div>
</div>
New contributor
mohxn ayaz is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |
up vote
0
down vote
up vote
0
down vote
You are giving height in %
please change it to px
.portfolio-img {
width: 45%;
height: 300px; /* ---> give height it as you want */
margin-top: 2rem;
margin-left: 1rem;
}
<div class="container">
<div class="row">
<img src="images/img3.jpg" class="portfolio-img">
<img src="images/img1.jpg" class="portfolio-img">
<img src="images/img2.jpg" class="portfolio-img">
<img src="images/img4.jpg" class="portfolio-img">
</div>
</div>
New contributor
mohxn ayaz is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
You are giving height in %
please change it to px
.portfolio-img {
width: 45%;
height: 300px; /* ---> give height it as you want */
margin-top: 2rem;
margin-left: 1rem;
}
<div class="container">
<div class="row">
<img src="images/img3.jpg" class="portfolio-img">
<img src="images/img1.jpg" class="portfolio-img">
<img src="images/img2.jpg" class="portfolio-img">
<img src="images/img4.jpg" class="portfolio-img">
</div>
</div>
.portfolio-img {
width: 45%;
height: 300px; /* ---> give height it as you want */
margin-top: 2rem;
margin-left: 1rem;
}
<div class="container">
<div class="row">
<img src="images/img3.jpg" class="portfolio-img">
<img src="images/img1.jpg" class="portfolio-img">
<img src="images/img2.jpg" class="portfolio-img">
<img src="images/img4.jpg" class="portfolio-img">
</div>
</div>
.portfolio-img {
width: 45%;
height: 300px; /* ---> give height it as you want */
margin-top: 2rem;
margin-left: 1rem;
}
<div class="container">
<div class="row">
<img src="images/img3.jpg" class="portfolio-img">
<img src="images/img1.jpg" class="portfolio-img">
<img src="images/img2.jpg" class="portfolio-img">
<img src="images/img4.jpg" class="portfolio-img">
</div>
</div>
New contributor
mohxn ayaz is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
mohxn ayaz is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
answered 6 hours ago


mohxn ayaz
1
1
New contributor
mohxn ayaz is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
mohxn ayaz is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
mohxn ayaz is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |
add a comment |
up vote
0
down vote
I want something like that:
image
codepen.io/anon/pen/RqoxEJ
– Ciuca Cristi
5 hours ago
add a comment |
up vote
0
down vote
I want something like that:
image
codepen.io/anon/pen/RqoxEJ
– Ciuca Cristi
5 hours ago
add a comment |
up vote
0
down vote
up vote
0
down vote
I want something like that:
image
I want something like that:
image
answered 6 hours ago


Ciuca Cristi
11
11
codepen.io/anon/pen/RqoxEJ
– Ciuca Cristi
5 hours ago
add a comment |
codepen.io/anon/pen/RqoxEJ
– Ciuca Cristi
5 hours ago
codepen.io/anon/pen/RqoxEJ
– Ciuca Cristi
5 hours ago
codepen.io/anon/pen/RqoxEJ
– Ciuca Cristi
5 hours ago
add a comment |
up vote
0
down vote
There is a nice example in w3school website
https://www.w3schools.com/css/tryit.asp?filename=trycss3_flexbox_image_gallery
In summary you use display flex and divide the images into columns
This is the result for your case
.container {
display: flex;
flex-wrap: wrap;
}
.row {
flex: 50%;
max-width: 50%;
}
.portfolio-img {
width:100%;
vertical-align: middle;
}
<div class="container">
<div class="row">
<img src="https://images.pexels.com/photos/1089562/pexels-photo-1089562.jpeg?auto=compress&cs=tinysrgb&h=750&w=1260" class="portfolio-img filter development">
<img src="https://images.pexels.com/photos/1037996/pexels-photo-1037996.jpeg?auto=compress&cs=tinysrgb&h=750&w=1260" class="portfolio-img filter marketing">
</div>
<div class="row">
<img src="https://images.pexels.com/photos/1037995/pexels-photo-1037995.jpeg?auto=compress&cs=tinysrgb&h=750&w=1260" class="portfolio-img filter development">
<img src="https://images.pexels.com/photos/1037999/pexels-photo-1037999.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=750&w=1260" class="portfolio-img filter design">
</div>
</div>
add a comment |
up vote
0
down vote
There is a nice example in w3school website
https://www.w3schools.com/css/tryit.asp?filename=trycss3_flexbox_image_gallery
In summary you use display flex and divide the images into columns
This is the result for your case
.container {
display: flex;
flex-wrap: wrap;
}
.row {
flex: 50%;
max-width: 50%;
}
.portfolio-img {
width:100%;
vertical-align: middle;
}
<div class="container">
<div class="row">
<img src="https://images.pexels.com/photos/1089562/pexels-photo-1089562.jpeg?auto=compress&cs=tinysrgb&h=750&w=1260" class="portfolio-img filter development">
<img src="https://images.pexels.com/photos/1037996/pexels-photo-1037996.jpeg?auto=compress&cs=tinysrgb&h=750&w=1260" class="portfolio-img filter marketing">
</div>
<div class="row">
<img src="https://images.pexels.com/photos/1037995/pexels-photo-1037995.jpeg?auto=compress&cs=tinysrgb&h=750&w=1260" class="portfolio-img filter development">
<img src="https://images.pexels.com/photos/1037999/pexels-photo-1037999.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=750&w=1260" class="portfolio-img filter design">
</div>
</div>
add a comment |
up vote
0
down vote
up vote
0
down vote
There is a nice example in w3school website
https://www.w3schools.com/css/tryit.asp?filename=trycss3_flexbox_image_gallery
In summary you use display flex and divide the images into columns
This is the result for your case
.container {
display: flex;
flex-wrap: wrap;
}
.row {
flex: 50%;
max-width: 50%;
}
.portfolio-img {
width:100%;
vertical-align: middle;
}
<div class="container">
<div class="row">
<img src="https://images.pexels.com/photos/1089562/pexels-photo-1089562.jpeg?auto=compress&cs=tinysrgb&h=750&w=1260" class="portfolio-img filter development">
<img src="https://images.pexels.com/photos/1037996/pexels-photo-1037996.jpeg?auto=compress&cs=tinysrgb&h=750&w=1260" class="portfolio-img filter marketing">
</div>
<div class="row">
<img src="https://images.pexels.com/photos/1037995/pexels-photo-1037995.jpeg?auto=compress&cs=tinysrgb&h=750&w=1260" class="portfolio-img filter development">
<img src="https://images.pexels.com/photos/1037999/pexels-photo-1037999.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=750&w=1260" class="portfolio-img filter design">
</div>
</div>
There is a nice example in w3school website
https://www.w3schools.com/css/tryit.asp?filename=trycss3_flexbox_image_gallery
In summary you use display flex and divide the images into columns
This is the result for your case
.container {
display: flex;
flex-wrap: wrap;
}
.row {
flex: 50%;
max-width: 50%;
}
.portfolio-img {
width:100%;
vertical-align: middle;
}
<div class="container">
<div class="row">
<img src="https://images.pexels.com/photos/1089562/pexels-photo-1089562.jpeg?auto=compress&cs=tinysrgb&h=750&w=1260" class="portfolio-img filter development">
<img src="https://images.pexels.com/photos/1037996/pexels-photo-1037996.jpeg?auto=compress&cs=tinysrgb&h=750&w=1260" class="portfolio-img filter marketing">
</div>
<div class="row">
<img src="https://images.pexels.com/photos/1037995/pexels-photo-1037995.jpeg?auto=compress&cs=tinysrgb&h=750&w=1260" class="portfolio-img filter development">
<img src="https://images.pexels.com/photos/1037999/pexels-photo-1037999.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=750&w=1260" class="portfolio-img filter design">
</div>
</div>
.container {
display: flex;
flex-wrap: wrap;
}
.row {
flex: 50%;
max-width: 50%;
}
.portfolio-img {
width:100%;
vertical-align: middle;
}
<div class="container">
<div class="row">
<img src="https://images.pexels.com/photos/1089562/pexels-photo-1089562.jpeg?auto=compress&cs=tinysrgb&h=750&w=1260" class="portfolio-img filter development">
<img src="https://images.pexels.com/photos/1037996/pexels-photo-1037996.jpeg?auto=compress&cs=tinysrgb&h=750&w=1260" class="portfolio-img filter marketing">
</div>
<div class="row">
<img src="https://images.pexels.com/photos/1037995/pexels-photo-1037995.jpeg?auto=compress&cs=tinysrgb&h=750&w=1260" class="portfolio-img filter development">
<img src="https://images.pexels.com/photos/1037999/pexels-photo-1037999.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=750&w=1260" class="portfolio-img filter design">
</div>
</div>
.container {
display: flex;
flex-wrap: wrap;
}
.row {
flex: 50%;
max-width: 50%;
}
.portfolio-img {
width:100%;
vertical-align: middle;
}
<div class="container">
<div class="row">
<img src="https://images.pexels.com/photos/1089562/pexels-photo-1089562.jpeg?auto=compress&cs=tinysrgb&h=750&w=1260" class="portfolio-img filter development">
<img src="https://images.pexels.com/photos/1037996/pexels-photo-1037996.jpeg?auto=compress&cs=tinysrgb&h=750&w=1260" class="portfolio-img filter marketing">
</div>
<div class="row">
<img src="https://images.pexels.com/photos/1037995/pexels-photo-1037995.jpeg?auto=compress&cs=tinysrgb&h=750&w=1260" class="portfolio-img filter development">
<img src="https://images.pexels.com/photos/1037999/pexels-photo-1037999.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=750&w=1260" class="portfolio-img filter design">
</div>
</div>
answered 4 hours ago


Eric Marcelino
29122
29122
add a comment |
add a comment |
up vote
0
down vote
I succeeded with this codepen.io/ms_yogi/pen/zpEXba. Thank you all!
add a comment |
up vote
0
down vote
I succeeded with this codepen.io/ms_yogi/pen/zpEXba. Thank you all!
add a comment |
up vote
0
down vote
up vote
0
down vote
I succeeded with this codepen.io/ms_yogi/pen/zpEXba. Thank you all!
I succeeded with this codepen.io/ms_yogi/pen/zpEXba. Thank you all!
answered 4 hours ago


Ciuca Cristi
11
11
add a comment |
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53265432%2fhtml-photo-gallery-remove-space%23new-answer', 'question_page');
}
);
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
XMkNjIWmf3qQCsfK8tEhAcp,3XXzRmd,0mUchrwatDHyboF,pz82ivQFXn7upl,mP93IE 33sh1GegvGHoh3,jBslDq8OyhJbDWTEc
it is not clear what you want - perhaps you mean something like masonry.desandro.com
– mplungjan
7 hours ago
Please edit the snippet I made and add images from lorempixel.com or similar
– mplungjan
7 hours ago
Have a look at codepen.io/jensimmons/pen/XdBxav
– George
7 hours ago