Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why are my images not stuck together?

Tags:

html

css

I have this simple HTML / CSS

<div class="image-group">
  <img src="http://placehold.it/80x80" />
  <img src="http://placehold.it/120x120" />
  <img src="http://placehold.it/80x80" />
</div>

.image-group img {
  margin: 0;
  padding: 0;
}

JSFiddle

Why are the images not stuck together? I inspect the elements using Chrome's Inspector and it shows me nothing in between the images, yet they are spaced out.

I can get them to stick together by applying negative margins, but according to me, they should be sticking together anyways.

like image 795
xbonez Avatar asked Dec 16 '22 15:12

xbonez


2 Answers

There's space in your html code. Try below

<div class="image-group">
    <img src="http://placehold.it/80x80" /><img src="http://placehold.it/120x120" /><img src="http://placehold.it/80x80" />
</div>
like image 93
SangYeob Bono Yu Avatar answered Jan 31 '23 20:01

SangYeob Bono Yu


Check out this blog post about dealing with spaces with consecutive inline-block elements such as images.

http://css-tricks.com/fighting-the-space-between-inline-block-elements/

like image 26
RyanFishman Avatar answered Jan 31 '23 20:01

RyanFishman