Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <h2>A vertically oriented ordered  list broken into 2 columns using CSS selectors</h2>
<a href="https://codepen.io/noahblon" title="Go to the Codepen profile of Noah Blon" rel="author">by Noah Blon</a>
<p>Since IE9 doesnt support CSS3 columns, or flexbox, here's an IE9+ method for creating a vertically oriented ordered list that breaks to two columns without needing extra elements, classes, or JS.</p>  
  
<h3>1<sup>st</sup>  Column contains more items if there are a total odd number of items</h3>

<ol class="roundDown">
  <li>Aloe</li>
  <li>Bergamot</li>
  <li>Calendula</li>
  <li>Damiana</li>
  <li>Elderflower</li>
  <li>Feverfew</li>
  <li>Ginger</li>
  <li>Hops</li>
  <li>Iris</li>
  <li>Juniper</li>
  <li>Kava kava</li>
  <li>Lavender</li>
  <li>Marjoram</li>
  <li>Nutmeg</li>
  <li>Oregano</li>
  <li>Pennyroyal</li>
  <li>Marjoram</li>
  <li>Nutmeg</li>
  <li>Oregano</li>
  <li>Pennyroyal</li>
  <li>Marjoram</li>
  <li>Nutmeg</li>
  <li>Oregano</li>
</ol>

<h3>2<sup>nd</sup> Column contains more items if there are a total odd number of items</h3>
<ol class="roundUp">
  <li>Aloe</li>
  <li>Bergamot</li>
  <li>Calendula</li>
  <li>Damiana</li>
  <li>Elderflower</li>
  <li>Feverfew</li>
  <li>Ginger</li>
  <li>Hops</li>
  <li>Iris</li>
  <li>Juniper</li>
  <li>Kava kava</li>
  <li>Lavender</li>
  <li>Marjoram</li>
  <li>Nutmeg</li>
  <li>Oregano</li>
  <li>Pennyroyal</li>
  <li>Marjoram</li>
  <li>Nutmeg</li>
  <li>Oregano</li>
  <li>Pennyroyal</li>
  <li>Marjoram</li>
  <li>Nutmeg</li>
  <li>Oregano</li>
</ol>

<h3> How it works</h3>
<p>All items are absolutely positioned based on the line height using nth-child.  The items in the second column are selected with nth-child using a clever trick to select half the items.  This overrides the initial absolute position styling.  The second columns is staticly positioned and pushed right with margin.   I've used Sass to make generating these rules easier but its not required. One caveat is that you'll need to know the maximum number of items that might be held in a single column.  It will work for any number of items below that value.  In addition, this positioning will only work with items that will fit on a single line.</p>

<h3>Additional Resources</h3>
<ul>
  <li><a href="http://alistapart.com/article/multicolumnlists" title="A list Apart article about multicol lists">Here's an old A List Apart article containing some other solutions which require specific classing</a></li>
  <li><a href=" https://codepen.io/keithclark/full/Hygkt" title="demo by Keith Clark" >An awesome and useful demo by Keith Clark with advanced CSS Selector usage</a></li>
</ul>
    
<footer>
  <a href="https://codepen.io/noahblon/details/Agpyc#comment-list">Thoughts? Comment on this Pen</a>
</footer>

              
            
!

CSS

              
                $max-column-items: 12; /* The maximum number of items a single column can handle.  If a column has more items than the maximum defined here, some items won't display. */
$line-height: 1.5; 
$list-font-size: 16px;

ol {
  position: relative;
  margin: 0 0 50px;
  padding: 0;
  font-size: $list-font-size;
}

ol li {
  position: absolute;
  margin: 0;
  padding: 0;
  width: 50%;
  background: #b3cae5;
  list-style-position: inside;
  line-height: $line-height;
}

@for $i from 2 through $max-column-items{
  ol li:nth-child(n+#{$i}){
    top: $line-height * ($i - 1) + em; /* line height is equal to the absolute position top for all items. will only effect first column because overridden later*/
  }
}

/* Round up puts more items in first column if odd total number of items 
*/
@for $i from 2 through $max-column-items {
  .roundUp li:nth-child(n+#{$i}):nth-last-child(-n+#{$i}) {
    position: static;
    margin-left: 50%;
    background: #efcab2;
  }
}

/* Round Down puts more items into second column if odd total number of items 
*/
@for $i from 2 through $max-column-items {
  .roundDown li:nth-child(n+#{$i + 1}):nth-last-child(-n+#{$i}) {
    position: static;
    margin-left: 50%;
    background: #efcab2;
  }
}

/* BASE STYLING */
body { padding: 3% 10%; font-size: 16px; font-family: Helvetica, Arial, sans-serif; }

footer { padding-top: 25px; border-top: 1px solid black; }
              
            
!

JS

              
                
              
            
!
999px

Console