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

Auto Save

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

              
                <h1>SASS mixin for Element Queries (EQ)</h1>
<p class="details">
  Following boxes position themselves depending on 2 main params:<br>
  <span>
    a) on the viewport width<br>
    b) on the number of the elements every row should have
  </span>
  Apart from these, there is an optional param which determines whether or not a line should break into multiple lines.<br><br>
  Resize the window to view the results.
</p>

<ul class="minisku">
  <li class="card"></li>
  <li class="card"></li>
  <li class="card"></li>
  <li class="card"></li>
  <li class="card"></li>
  <li class="card"></li>
  <li class="card"></li>
  <li class="card"></li>
  <li class="card"></li>
  <li class="card"></li>
  <li class="card"></li>
</ul>

<p>Feel free to use the function!</p>

<p class="bottom">Written for Schwartz v. of <a href="https://skroutz.gr">Skroutz</a></p>


              
            
!

CSS

              
                @import url(https://fonts.googleapis.com/css?family=Roboto:100);

html {
  line-height: 1.4;
  padding: 50px 20px;
  background: #f1f1f1;  
  text-align: center;
  font-size: 20px;
  font-family: "Roboto", Georgia;
}

.minisku {
  list-style: none;
  overflow: hidden;
  
  &:after {
    content: "";
    display: table;
    clear: both;
  }

  .card {
    border: none;
    height: 200px;
    background: #FF5733;
    margin: 0 auto 20px;

    &:hover {
      box-shadow: 2px 2px 3px 0 rgba(grey, 0.2);
    }

    a {
      color: black;
      font-size: 12px;

      &:before { // Make all card clickable
        content: "";
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
      }

      &:active:before {
        box-shadow: 2px 2px 3px 0 rgba(grey, 0.2);
      }
    }
  }
}

// Element Query

@mixin minisku-element-query($viewport, $items_per_line, $break_lines: false) {

  @media (min-width: #{$viewport}) {
    
    $item_percentage: percentage(1 / $items_per_line);
    
    > li {
      width: calc(#{$item_percentage} - 20px);
      float: left;
    }

    > li:nth-child(n) { // Cancel float clearance
      clear: none;
      margin: 0 20px 20px 0;
    }

    @if $break_lines == true {
      
      > li:nth-child(n) {
      }

      > li:nth-child(#{$items_per_line}n) {
        margin-right: 0;
      }

      > li:nth-child(#{$items_per_line}n+1) {
        clear: both;
      }
    }
    
    @else {
      white-space: nowrap;

      > li {
        float: none;
        display: inline-block;
      }
    }
  }
}

.minisku {
  @include minisku-element-query(350px, 2);  
}

.minisku {
  @include minisku-element-query(650px, 3, true);  
}

.minisku {
  @include minisku-element-query(850px, 4, true);
}

.minisku {
  @include minisku-element-query(1050px, 5);
}

.minisku {
  @include minisku-element-query(1250px, 6, true);
}

h1 {
  font-size: 40px;
}

p {
  font-size: 20px;
  margin: 0 auto 40px;
  color: #707070;
}

.details {
  max-width: 700px;
  text-align: left;
  
  > span {
    display: block;
    margin: 5px 20px 15px 20px;
  }
}

.bottom {
  font-size: 24px;
  color: #999;
  
  > a {
    text-decoration: none;
    color: #f68b24;
  }
}
              
            
!

JS

              
                
              
            
!
999px

Console