Exploring a column newspaper-like layout has led me to wonder if there is a way to use CSS or JavaScript to identify columns (or column breaks) and dynamically insert content between them with JavaScript.
The concept involves having a layout with 100% height where columns extend to the right of the screen, similar to this example : . What I am seeking to achieve is inserting an additional column after the first one, before the second one, and populate it with content such as images or extra links.
I understand how to add content using JavaScript with innerHtml and have also discovered methods to count the number of columns (Get number of columns created by css column-width or How to get css3 multi-column count in Javascript). However, I am unclear on how to obtain the class or ID of a specific column or column break in order to append HTML content accurately.
Is it feasible to instruct the browser through code to "add another column after column #1" or "insert content of 100% height after column #1" or even "create an empty space of XXpx after column #1 (and display an absolutely-positioned div)"?
An illustrative example can be viewed here:
For reference, here's a quick fiddle demonstrating basic HTML/CSS columns: https://jsfiddle.net/p8ar0zpr/1/
<div class="example">
<h1>Sed dignissim lacinia nunc</h1>
<p class="lead">Aenean quam. In scelerisque sem at dolor. Sed convallis tristique sem.</p>
<p>Morbi lectus risus, iaculis vel, suscipit quis, luctus non, massa. Fusce ac turpis quis ligula lacinia aliquet. </p>
<p>Mauris ipsum. Nulla metus metus, ullamcorper vel, tincidunt sed, euismod in, nibh. Quisque volutpat condimentum velit. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. </p>
</div>
.example {
-webkit-columns: 320px;
-moz-columns: 320px;
columns: 320px;
-webkit-column-gap: 2em;
-moz-column-gap: 2em;
column-gap: 2em;
height:95%;
padding:1em;
}
html{height:100%;}
body {
font-size: 12px;
font-family: 'Georgia', serif;
font-weight: 400;
line-height: 1.45;
color: #333;
background: #ecf0f1;
padding: 0;
margin:0;
height:100%;
}
h1 {
font-size: 2em;
margin-bottom: 0.5em;
line-height: 1.2;
}
p {
margin-bottom: 1.3em;
text-align: justify;
}
.lead {
font-variant: small-caps;
font-size: 1.3em;
text-align: left;
font-style: italic;
}
Thank you for your assistance!