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

Quick-add: + add another resource

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.

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.

            
              <div id="console">
</div>

  <div id="blue">
    blue
  </div>
  <div id="red">
    red
  </div>

  <div id="green">
    green
  </div>
  <div id="orange">
    orange
  </div>
<div id="handle"></div>
<style type="text/gss">
  
  //Horizontal Layout
  @h |(#blue)(#red)| in(::window) !strong;
  @h |(#green)(#orange)| in(::window) !strong;
  
  //Vertical Layout
  @v |(#blue)(#green)| in(::window) !strong;
  @v |(#red)(#orange)| in(::window) !strong;
  
  
  #blue[width] == $varX;
  #green[width] == $varX;
  
  #blue[bottom] == $varY;
  #red[bottom] == $varY;
    
  #handle {
    center-y : == $varY !weak;
    center-x : == $varX !weak;
    size : == 20;
  }

  #console {
    center-x: ==::window[center-x];
    width: == 200;
    height: == 50;
  }

  
  
  //Uncomment to add constraints
  
  
  #green[width] >= 300;
  #blue[width] >= 150;
  
  #red[width] >= 300;
  #orange[width] >= 150;
  /*
  #blue[height] >= 150;
  #green[height] >= 100;
  
  #red[height] >= 150;
  #orange[height] >= 100;
  */
  
</style>
<script src="https://s3-us-west-2.amazonaws.com/cdn.thegrid.io/gss/v2.0.0/v2.0.0/gss.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.0.0-alpha1/jquery.min.js"></script>

<script src="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.11.4/jquery-ui.min.js"></script>



<script type="text/javascript">


  
</script>


            
          
!
            
              
body {
  font-family: "museo-sans",sans-serif;
  font-style: normal;
  font-weight: 500;
  color: black;
  background-color: #333;
}

div {
  box-sizing: border-box;
  text-align: center;
  padding: 20px; 
  color: white;
}


article {
  background-color: blue;
}

#blue {
  background-color: #04617B;
}
#red {
  background-color: #C60A00;
}

#green {
  background-color: #009913;
}



#orange {
  background-color: #C66400;
}

  #handle {
  border-radius: 50%;
    border : 3px solid black;
  background-color: white;
    padding: 0;
    opacity: 0.5;
    
  }
#handle:hover {
  opacity: 1;
}

#console {
  background-color: #333;
  z-index: 1000;
  opacity: 0.8;
  font-family: Courier;
  visibility: hidden;
}

            
          
!
            
                 window.engine = new GSS(document, {
          varX: 400,
          varY: 300
        });
  
  
  

  $.widget('ui.custommouse', $.ui.mouse, {
  options: {
    mouseStart: function() {},
    mouseDrag: function() {},
    mouseStop: function() {},
    mouseCapture: function() {
      return true;
    }
  },
  // Forward events to custom handlers
  _mouseStart: function(e) {
    return this.options.mouseStart(e);
  },
  _mouseDrag: function(e) {
    return this.options.mouseDrag(e);
  },
  _mouseStop: function(e) {
    return this.options.mouseStop(e);
  },
  _mouseCapture: function(e) {
    return this.options.mouseCapture(e);
  },
  // Bookkeeping, inspired by Draggable
  widgetEventPrefix: 'custommouse',
  _init: function() {
    return this._mouseInit();
  },
  _create: function() {
    return this.element.addClass('ui-custommouse');
  },
  _destroy: function() {
    this._mouseDestroy();
    return this.element.removeClass('ui-custommouse');
  },
});


$('#handle').custommouse({
  mouseDrag: function(e) {
    $('#console').text('x : ' + e.clientX + ', y : ' + e.clientY)
    //Uncomment to recalculate layout at drag
      
      window.engine.solve({
        varY: e.clientY,
        varX: e.clientX
      });
      
  },
  mouseStart: function(e) {
    $('#console').css('visibility', 'visible')
  },
  mouseStop: function(e) {
    $('#console').css('visibility', 'hidden')
  }

});
            
          
!
999px
Loading ..................

Console