Pen Settings



CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource


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


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.


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.


                //The slice, sort, and for loop are not necessary.  However, they are there for your conveinence when adding new price keys.  If you want to drop those things, then you would have to add and change a new "order" key & value each time you add a new price key & value.  For example, in this demo, $245 is the highest price.  You would want a priceAry.order value of 0 for it (or the corresponding CSS order property value).  You can see how manual changes can become unmaintainable.  I wanted to handle this side of things in the template and not on the client side JS.
- var priceAry = [{"price":"25"},{"price":"245"},{"price":"15"},{"price":"55"},{"price":"50"},{"price":"35"},{"price":"75"},{"price":"150"},{"price":"175"},{"price":"55"},{"price":"125"},{"price":"100"}]
- var newAry = priceAry.slice(0);
- priceAry.sort(function(a, b){
 - return b.price-a.price
- })
- for (var i = 0; i < priceAry.length; i++) {
  - priceAry[i].order = i
- }
  button#default Arrange by relevance (default)
  button#high-to-low Arrange highest to lowest
  button#low-to-high Arrange lowest to highest
  each val, index in newAry
    li(class="sortable", data-order=val.order, data-default=index)
      span.price= "$" + val.price



                //reset & autoprefixed used
//I didn't use any transitions during the sort.  I wanted to keep the concept extremely simple.  Maybe in the future I'll add some cool transitions during the sort.
body, html {
  height: 100%;
  font-size: 100%
.button-wrapper {
  display: flex;
  flex-flow: row wrap;
  justify-content: space-around;
  background: lighten(lightblue,13%);
  padding-bottom: 10px;
button {
  font: 1.3rem 'Open Sans Condensed', sans-serif;
  padding: 10px;
  margin-top: 10px;
  cursor: pointer;
  border: none;
  background: rgb(55,55,55);
  color: #fff;
  font-family: 'Open Sans Condensed', sans-serif;
  transition: background 0.3s ease-in-out
button:hover {
  background: rgb(105,105,105);
ul {
  list-style: none;
  min-height: 100%;
  display: flex;
  flex-flow: row wrap;
  justify-content: space-around;
  align-items: center;
  background: lighten(lightblue,17%);
  padding-top: 20px
.sortable {
  display: flex;
  flex-flow: column nowrap;
  padding-bottom: 20px;
  width: calc(25% - 40px);
  transition: opacity 0.3s ease-in-out,
.hidden {
  opacity: 0
.fake-image, .price {
  width: 100%;
  text-align: center;
  background: #fff;
.fake-image {
  font-size: 7rem;
  color: darken(DarkGreen,5%);
  padding-top: 10px
.price {
  font: 1.7rem "Oswald", sans-serif;
  color: rgb(75,75,75);
//Some simple media queries
@media only screen and (max-width: 768px) {
  .sortable {
    width: calc(50% - 20px)
@media only screen and (max-width: 480px) {
  .sortable {
    width: 100%


                //Tested in Chrome, Firefox, & IE11
//No jQuery used.  I wanted to keep it as fast and lightweight as possible

/*You are probably thinking to yourself, hey why not use row-reverse on the grid id?  I tried that originally, but is was only reversing individual rows.  If you wanted multiple rows then you were out of luck.  This works even better.*/
function sortItems(dataType,neg) {
  neg = neg || "";
  var delay = 0;
  var sortable = document.querySelectorAll(".sortable");
 for (var i = 0; i < sortable.length; i++) {
   var dataSelect = document.querySelector("[data-default='" + i + "']") = 0; = (delay += 0.02) + "s";
  sortable[sortable.length-1].addEventListener("transitionend", function(){
    for (var i = 0; i < sortable.length; i++) {
    //Get the element by data-order and change the order style.  That's all you have to do!  You could probably substitute data-order for an id, but the data attribute seemed more logical
    var dataSelect = document.querySelector("[data-" + dataType + "='" + i + "']") = neg + i; = 1; = (delay -= 0.02) + "s";