If you want to move text to the next column, consider experimenting with CSS properties like float
and clear
.
Here's an example that demonstrates pushing a title to the next column using a CSS variable to redefine the height of the clearer.
// You can turn this code snippet into a function that triggers on page load or resize
var getIt = document.getElementById("test1");
var thisTall = getIt.offsetHeight + "px";
getIt.style.setProperty("--hgt", thisTall);
div {
column-count: 2;
border: solid;
column-fill: balance;
}
div::before {
content: '.';
float: left;
min-height: var(--hgt);
width: 3px;
background: red;
}
h2, p::first-line {
clear: both;
color: red;
float: left;
width: 100%;
margin-top: 0;
text-align: center;
}
p {text-align:justify}
<div id="test1">
<h2>Title sent to next column</h2>
<p>!! the script is not fired on resize !! <br> Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas...</p>
</div>
Visit Codepen to experiment further.
The introductory text is positioned at the top for easier alignment with floating elements.