cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External CSS

These stylesheets will be added in this order and before the code you write in the CSS editor. You can also add another Pen here, and it will pull the CSS from it. Try typing "font" or "ribbon" below.

Quick-add: + add another resource

Add External JavaScript

These scripts will run in this order and before the code in the JavaScript editor. You can also link to another Pen here, and it will run the JavaScript from it. Also try typing the name of any popular library.

Quick-add: + add another resource

Code Indentation

     

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.

            
              <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>


            
          
!
            
              @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;
  }
}
            
          
!
999px
Loading ..................

Console