-1

Why is that <a> tag gets height in below example jsfiddle

I guess that's why my margins on feature class don't work as expected.

Sample of code

.feature {
  margin: 0;
  position: relative;
  margin: 10px 0;
}

.feature__caption {
  position: absolute;
  bottom: 5px;
  color: #c158ad;
  text-align: center;
  width: 100%;
  font-size: 1.5em;
  padding: 2% 0;
  right: 0;
  left: 0;
}
<div class="col span_4_of_12">
  <figure class="feature">
    <a href="#">
      <img src="http://via.placeholder.com/350x150" alt="shoes">
      <figcaption class="feature__caption">ACCESSORIES</figcaption>
    </a>
  </figure>
  <figure class="feature">
    <a href="#">
      <img src="http://via.placeholder.com/350x150" alt="shoes">
      <figcaption class="feature__caption">LATEST FASHION</figcaption>
    </a>
  </figure>
</div>
Vadim Ovchinnikov
  • 13,327
  • 5
  • 62
  • 90
Przemek85
  • 171
  • 1
  • 1
  • 10

1 Answers1

1

Not sure if this is what you want. Try it out.

.feature img {
  display: block;  
}

Browsers technically use display: inline (as you can see in the developer tools), for img tags. Anyway images get somehow a special treatment and their default display is very much like the one of an inline-block element.

Marco Magrini
  • 749
  • 1
  • 9
  • 19