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

              
                <head>
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
  <script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.10.2/jquery-ui.min.js"></script>
    <script src="script.js"></script>
    <link rel="stylesheet" href="style.css">
</head>

<body>
<div id="blockTray">
  
<figure id="catlover" class="block">
  <div></div>
  <p class="recenter" >catlover</p>
</figure>
  
<figure id="cook" class="block">
  <div></div>
  <p class="recenter">cook</p>
</figure>
  
<figure id="journalist" class="block">
  <div></div> 
  <p class="recenter" >journalist</p>
</figure>
  
<figure id="photographer" class="block">
   <div></div>
   <p class="recenter">photographer</p>
</figure>

<figure id="translator" class="block">
  <div></div>
  <p class="recenter">translator</p>
</figure>
  
<figure id="illustrator" class="block">
  <div></div>
  <p class="recenter">illustrator</p>
 </figure>
  
 <figure id="videographer" class="block">
   <div></div>
   <p class="recenter">videographer</p>
</figure>
  
</div>

<div id="canvas">
    <div id=rectangle>
       <!-- Generator: Adobe Illustrator 22.0.1, SVG Export Plug-In  -->
<svg version="1.1"
	 xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:a="http://ns.adobe.com/AdobeSVGViewerExtensions/3.0/"
	 x="0px" y="0px" width="305.9px" height="197px" viewBox="0 0 305.9 197" style="enable-background:new 0 0 305.9 197;"
	 xml:space="preserve">
<style type="text/css">
	.st0{fill:none;stroke:#000000;stroke-miterlimit:10;}
	.st1{font-family:'MyriadPro-Regular';}
	.st2{font-size:14px;}
</style>
<defs>
</defs>
<g>
	<line class="st0" x1="0" y1="0.8" x2="150.4" y2="0.8"/>
	<line class="st0" x1="2.4" y1="146" x2="1.2" y2="0.6"/>
	<line class="st0" x1="150.4" y1="1" x2="2.4" y2="146"/>
	<line class="st0" x1="305" y1="196.5" x2="154.4" y2="196.3"/>
	<line class="st0" x1="305.4" y1="52.8" x2="304.8" y2="196.7"/>
	<line class="st0" x1="154.5" y1="196.2" x2="305.2" y2="52.9"/>
	<line class="st0" x1="152.4" y1="1" x2="251.8" y2="1.4"/>
	<line class="st0" x1="253.4" y1="103" x2="150.7" y2="0.4"/>
	<line class="st0" x1="253.1" y1="101.9" x2="251.4" y2="1"/>
	<line class="st0" x1="252.8" y1="2.3" x2="304.8" y2="52.4"/>
	<line class="st0" x1="106.4" y1="146" x2="205.8" y2="146.4"/>
	<line class="st0" x1="55.4" y1="196" x2="154.8" y2="196.4"/>
	<line class="st0" x1="53.8" y1="196.1" x2="107.4" y2="146"/>
	<line class="st0" x1="2.8" y1="146.3" x2="54.8" y2="196.4"/>
	<line class="st0" x1="100.4" y1="50.2" x2="199.8" y2="50.2"/>
	<line class="st0" x1="54.8" y1="96.3" x2="106.8" y2="146.4"/>
	<text transform="matrix(1 0 0 1 89.4765 104.8954)" class="st1 st2">Xiaozhang (Shaw) Wan</text>
</g>
</svg>
</div>

<div id="instructions">
  <p>Click to rotate the blocks. Drag to build a shape.</p>
</div>

</div>

</body>

              
            
!

CSS

              
                /*blocks*/
figure{
  position: relative;
  width: 100px;
  height: 100px;
}

figure *{
  position: absolute;
}

figure div{
  width: 100%;
  height: 100%;
}

.recenter{
  font-size: 10px;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-weight:bold;
}

/* individual blocks*/
#catlover {
  width: 76px;
  height: 76px; 
}

#catlover div{
  transform: rotate(-45deg);
  background-color: #F48400;
}

#cook{
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 0 50px 50px 50px;
  border-color: transparent transparent #d2696a transparent;
}

#cook p{
  top: 25px;
}

#journalist {
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 107px 0 107px 107px;
  border-color: transparent transparent    transparent #FBC002;
  top:-100px;
}

#journalist p{
  transform: rotate(-45deg);
  left: -85px;
}

#photographer{
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 107px 107px 0 107px;
  border-color: #b20000 transparent transparent transparent;
  top:-100px;
}

#photographer p{
  transform: rotate(225deg);
  top: -75px;
  left: -30px;
}

#translator {
  width: 0;   
  height: 0;
  border-style: solid;
  border-width: 0 0 104px 104px;
  border-color: transparent transparent #81b442 transparent;
  top:-300px;
}

#translator p{
  transform: rotate(90deg);
  top: 70px;
  left: -65px;
}


#illustrator{
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 50px 50px 50px 0;
  border-color: transparent #66cdaa transparent transparent;
  top: -350px;
}

#illustrator p{
  transform: rotate(180deg);
  left:5px;
}

#videographer {
  width: 104px;
  height: 50px;
  top:-350px;
}

#videographer div{
  transform:skew(-45deg);
  background: #6495ed;
}
   
/*Page layout*/
#blockTray {
  float: right;
  height: 100%;
  width: 20%;
  padding:5px;
}

#canvas {
  position: relative;
  height: 300px;
  width: 400px;
  vertical-align: top;
  background-color: #ecf0f1;
  border-radius: 30px;
  margin:100px;
}

#rectangle{
  position: absolute;
  top:30px;
  left: 50px;
}

#instructions{
  position: absolute;
  font-size:14px;
  line-height: 2px;
  top: 250px;
  left:70px;
}

html, body {
  height:100%;
  width:100%;
  background-size: cover;
}
              
            
!

JS

              
                $(document).ready(function() {

  $('.block').draggable({
      containment:'window',
      stack: '.block',
      snap: true,
      snapMode: 'outer',
      snapTolerance: 13,
    });

$('#blockTray').on('mousedown', function () {
  $('#instruction').fadeOut('slow');
  });

 // Make blocks rotate 45 deg on each click
var angle = 45;    

$('.block').click(function() {
           
  $(this).css ({
  '-webkit-transform': 'rotate(' + angle + 'deg)',
  '-moz-transform': 'rotate(' + angle + 'deg)',
  '-o-transform': 'rotate(' + angle + 'deg)',
  '-ms-transform': 'rotate(' + angle + 'deg)'
   });
  angle+=45;
   });
    
});
              
            
!
999px

Console