I'm using django and bootstrap, and I was wondering if there was a way to write in columns like a newspaper does. Obviously it is easy to create columns in bootstrap, but I was wondering how to have the text divide itself into the columns nicely so there is not one column that is longer. Also I would include a 'writers' section at the top of one of the columns so I would need to account for that.
I am thinking of just dividing the words in the columns by the number of columns but then I think that there would be one run on column, mostly because of the writers section.
Column Offsetting: Column offsetting is used to move or push a column from its original position to a specified width or space. To implement column offsetting we use the '. col-md-n' class with '. col-md-offset-n' class which pushes column by n columns.
Populate the 'row' div with 5 divs with class 'col'. Because Bootstrap 4.0+ grid system has now shifted to Flexbox, the columns will arrange by themselves into five equally sized DOM elements.
For browsers that support it, you can use columns
css3 property:
.twoColumns{
-webkit-column-gap: 20px;
-moz-column-gap: 20px;
column-gap: 20px;
-webkit-column-count: 2;
-moz-column-count: 2;
column-count: 2;
}
<div class="twoColumns">
Sed ut perspiciatis unde omnis iste natus error ...
</div>
If you need to support older browsers, you can use the polyfill here:
https://github.com/BetleyWhitehorne/CSS3MultiColumn
Include the script after your stylesheet and it will convert if neccessary:
<link rel="stylesheet" type="text/css" href="stylesheet.css" />
<script type="text/javascript" src="css3-multi-column.js"></script>
Or you can do it in Javascript with Columnizer like this:
$('.twoColumns').columnize({ columns: 2 });
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With