Your problem is due to collapsing margins - from https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Box_Model/Mastering_margin_collapsing:
Top and bottom margins of blocks are sometimes combined (collapsed) into a single margin whose size is the largest of the margins combined into it, a behavior known as margin collapsing.
To get around this, I would wrap the content of the li in a span or div and put your original li
padding on that, and then put the 3px margin as padding on your li
instead:
li {
list-style: none;
padding: 3px 0; /* this is in place of your margin */
}
li + li {
border-top: 1px solid #eff0f1;
}
li > span {
display: block;
padding: 5px 4px 6px 7px; /* this is you original li padding */
}
li:hover > span {
background-color: #f7f8f8;
}
<ul>
<li><span>something</span></li>
<li><span>something else</span></li>
<li><span>something else again</span></li>
</ul>
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…