CSS ' column-count' breaking <li> :before and :after in first column only

557 Views Asked by At

Im using css property 'column-count' in my HTML page and getting a broken UI enter image description here

As you have seen in the screenshot the "Column 1" li's :before and :after are breaking and working fine in "Column 2" and I have used the similar CSS for both the columns [Fiddle]

CSS

.two-column {
  column-count: 2;
    column-gap: 2rem;
    max-width: 100%;
}

.column-break {
  display: block;
    break-after: column;
}

.two-column li {
      position: relative;
    font-size: 1rem;
    font-weight: 500;
    padding: 5px 0 5px 20px;
    list-style-type: none;
    list-style:none;
}

.two-column li:before {
  content: "";
    position: absolute;
    left: 0px;
    width: 15px;
    height: 0.125rem;
    background-color: rgb(195, 51, 69);
    margin-top: 0.5rem;
}

.two-column li a {
display: block;
position: relative;
}

.two-column li a:after {
  content: "";
    position: absolute;
    width: 15px;
    border-radius: 50%;
    height: 15px;
    top: 3px;
    background-color: rgb(195, 51, 69);
    margin-left: 5px;
}

HTML

<div class="two-column">
<div>
<p><strong>Column 1</strong></p>
<ul>
<li><a href="#" target="_blank">Link</a></li>
<li><a href="#" target="_blank">Link</a></li>
<li><a href="#" target="_blank">Link</a></li>
</ul>
</div>
<span class="column-break"></span>
<div>
<p><strong>Column 2</strong></p>
<ul>
<li><a href="#" target="_blank">Link</a></li>
<li><a href="#" target="_blank">Link</a></li>
<li><a href="#" target="_blank">Link</a></li>
<li><a href="#" target="_blank">Link</a></li>
</ul>
</div>
</div>

My chrome version is 'Version 102.0.5005.63 (Official Build) (64-bit)'

1

There are 1 best solutions below

0
Kamal On

I have changed and added display: inline-block to the <li> and now it's working fine for me https://jsfiddle.net/78qy1z3h/ check here.

enter image description here

Thanks, guys :) ... cheers