1

.main{
  column-count: 2;
}

.main .list{
  background: #ccc;
  padding: 10px;
  list-style-type: none;
}

.main .list:hover{
  background: #11e;
}
<ul class="main">
 <li class="list">list-item-1</li>
 <li class="list">list-item-2</li>
 <li class="list">list-item-3</li>
 <li class="list">list-item-4</li>
 <li class="list">list-item-5</li>
 <li class="list">list-item-6</li>
 <li class="list">list-item-7</li>
</ul>

When I hover on the list-item-4 I can see the hover color covers some section on the second column as well. How can fix it?

bhansa
  • 7,282
  • 3
  • 30
  • 55

1 Answers1

4

You can use break-inside: avoid; to prevent the experienced behaviour.

You do not need to use vendor prefixes as usage of break-inside is already supported by more than 99% of the browsers according to caniuse.com

Please have a look at my JSFiddle to see it working.

dmuensterer
  • 1,875
  • 11
  • 26