Is there a way to ensure that the h2 header always stays with its list items, even if the number of list items varies? Currently, the header appears in one column and the lists appear in another column, causing them to be separated when the list count changes. See my code below:
ul li {
list-style-type: none;
}
.list-parent ul li a {
color: #428bca;
}
ul.list-parent {
columns: 2
}
.list-parent h2 {
margin: 15px 0;
}
<h2 class="heading">Main Heading</h2>
<div class="row">
<div class="col-sm-12">
<ul class="list-parent">
<li>
<h2>Sub Heading</h2>
<ul class="sub-list-parent">
<li>
<a href="">List items</a>
</li>
</ul>
</li>
...
</ul>
</div>
</div>
I've tried using divs instead of parent lis, but it creates uneven vertical gaps due to varying child ul sizes. Is there a dynamic workaround to ensure that the header always stays connected to its sibling ul no matter how many list items it contains?