<h1>
CSS Multi-Column: column-gap and column-rule demo
</h1>
<form>
<fieldset>
<label class="active">
<input type="radio" name="class" value="container--one" checked="checked" class="radio">
<code>gap: auto; column-rule: none;</code>
</label>
<label>
<input type="radio" name="class" value="container--two" class="radio">
<code>gap: 3em;
column-rule: dotted lightgrey;</code>
</label>
<label>
<input type="radio" name="class" value="container--three" class="radio">
<code>gap: 3em;
column-rule: 4em solid lightgrey; </code>
</label>
</fieldset>
</form>
<div class="container container--one" id="container">
<h2>
The heading
</h2>
<p>
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Error laudantium dicta maiores voluptatibus corporis aliquid placeat porro fugit? Voluptatibus impedit dolor nesciunt, corrupti reiciendis molestias minima amet itaque rem! Ipsam?
</p>
<p>
Donec ligula ligula, egestas non dignissim at, consequat ac purus. Mauris tempus tempor magna in congue. In congue sed massa sed fringilla. Nunc interdum metus sed eleifend finibus. Pellentesque mi magna, pharetra quis accumsan et, varius nec dolor.
</p>
<h2>
The another heading
</h2>
<p>
Sed tempus faucibus ante quis consequat. Nunc in dolor pretium, gravida lectus eu, ornare orci. Vestibulum lobortis pellentesque nibh in sagittis. Praesent eget rhoncus diam, id finibus ante. Nunc vulputate dolor quis felis ullamcorper, a maximus elit tempor.
</p>
<p>
Curabitur nec lacinia ipsum. Duis tortor nisl, imperdiet id nunc eget, gravida pretium erat. Quisque id neque fringilla, molestie ante nec, vulputate augue.
</p>
<p>
Vestibulum sed finibus ligula, et cursus sem. Vestibulum quis laoreet tellus. Vivamus interdum varius ultrices. Nullam accumsan eget dolor eget commodo. Praesent nec venenatis turpis, quis ultrices tortor.
</p>
</div>
xxxxxxxxxx
.container--one {
gap: auto;
column-rule: none;
}
.container--two {
gap: 3em;
column-rule: dotted lightgrey;
}
.container--three {
gap: 3em;
column-rule: 4em solid lightgrey;
}
/* ETC (Formatting only): */
body {
margin: 1.5em;
font-size: 130%;
font-family: sans-serif;
background: #F2F0EC;
color: #2E2C08;
}
.container {
border: 10px solid #2E2C08;
background: white;
padding: 1rem;
}
.box {
margin: 0.25rem;
padding: 0.5em;
text-align: center;
background: #e5e3de;
}
fieldset {
border: #abab9d 1px solid;
padding: 0;
margin-bottom: 2em;
}
label {
display: inline-block;
padding: 0.5em;
cursor: pointer;
}
.active {
background: #abab9d;
}
.container {
columns: 20em 3;
}
h2 {
margin-top: 0;
}
xxxxxxxxxx
var radios = document.querySelectorAll('.radio');
var container = document.getElementById('container');
radios.forEach(function(i){
i.addEventListener('click', function(el){
var clicked = el.currentTarget;
var active = clicked.parentElement.parentElement.querySelector('.active');
active && active.classList.remove('active');
clicked.parentElement.classList.add('active');
container.className = 'container '+clicked.value;
});
});
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.