Inline block overlaps container border in Chrome

Why does the inline block overlap the bottom border of the container in Chrome in the following test case?

HTML:

<ul>
  <li><a href="">test</a></li>
  <li><a href="">test</a></li>
  <li><a href="">test</a></li>
</ul>

      

CSS

ul {
  border-bottom: 1px solid red;
  font-size: 12px;
}
li a {
  display: inline-block;
  padding: 0.4em;
  background: yellow;
}

      

test case:

http://cssdeck.com/labs/5vu2eue5

+3


source to share


3 answers


In fact, I found a bug report .



Please post this issue if you are experiencing the same.

+2


source


If you don't care about bullet points, you can clear them with vertical alignment: at the bottom of the link element:



li a {
    vertical-align:bottom;
}

      

+1


source


It's all about calculating elements em

. Use round values em

like (0.5em, 1em ..), this will give correct results.

li a {
display: inline-block;
padding:0.5em;
background: yellow; 
} 

      

DEMO

0


source







All Articles