HTML preprocessors can make writing HTML more powerful or convenient. For instance, Markdown is designed to be easier to write and read for text documents and you could write a loop in Pug.
In CodePen, whatever you write in the HTML editor is what goes within the <body>
tags in a basic HTML5 template. So you don't have access to higher-up elements like the <html>
tag. If you want to add classes there that can affect the whole document, this is the place to do it.
In CodePen, whatever you write in the HTML editor is what goes within the <body>
tags in a basic HTML5 template. If you need things in the <head>
of the document, put that code here.
The resource you are linking to is using the 'http' protocol, which may not work when the browser is using https.
CSS preprocessors help make authoring CSS easier. All of them offer things like variables and mixins to provide convenient abstractions.
It's a common practice to apply CSS to a page that styles elements such that they are consistent across all browsers. We offer two of the most popular choices: normalize.css and a reset. Or, choose Neither and nothing will be applied.
To get the best cross-browser support, it is a common practice to apply vendor prefixes to CSS properties and values that require them to work. For instance -webkit-
or -moz-
.
We offer two popular choices: Autoprefixer (which processes your CSS server-side) and -prefix-free (which applies prefixes via a script, client-side).
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.
You can apply CSS to your Pen from any stylesheet on the web. Just put a URL to it here and we'll apply it, in the order you have them, before the CSS in the Pen itself.
If the stylesheet you link to has the file extension of a preprocessor, we'll attempt to process it before applying.
You can also link to another Pen here, and we'll pull the CSS from that Pen and include it. If it's using a matching preprocessor, we'll combine the code before preprocessing, so you can use the linked Pen as a true dependency.
JavaScript preprocessors can help make authoring JavaScript easier and more convenient.
Babel includes JSX processing.
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.
You can apply a script from anywhere on the web to your Pen. Just put a URL to it here and we'll add it, in the order you have them, before the JavaScript in the Pen itself.
If the script you link to has the file extension of a preprocessor, we'll attempt to process it before applying.
You can also link to another Pen here, and we'll pull the JavaScript from that Pen and include it. If it's using a matching preprocessor, we'll combine the code before preprocessing, so you can use the linked Pen as a true dependency.
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.
Using packages here is powered by Skypack, which makes packages from npm not only available on a CDN, but prepares them for native JavaScript ES6 import
usage.
All packages are different, so refer to their docs for how they work.
If you're using React / ReactDOM, make sure to turn on Babel for the JSX processing.
If active, Pens will autosave every 30 seconds after being saved once.
If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.
If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.
Visit your global Editor Settings.
<h1>FlagstoneJS <span class="yellow">4.0.0</span><span class="slogan">Dynamic & responsive tiling</span></h1>
<p class="quick-info"><span class="yellow">12.5 KB</span> | No dependencies | Loaded with options</p>
<div class="adjust">
<table>
<thead>
<tr>
<th>Property</th>
<th>Value</th>
</tr>
</thead>
<tbody>
<tr>
<td>margin:</td>
<td><input type="number" min="0" max="1000" disabled id="adjust-margin"></td>
</tr>
<tr>
<td>bedPadding:</td>
<td><input type="number" min="0" max="1000" value="10" id="adjust-bed-padding"></td>
</tr>
<tr>
<td>stonesMargin:</td>
<td><input type="number" min="0" max="1000" value="10" id="adjust-stones-margin"></td>
</tr>
<tr>
<td>minWidth:</td>
<td><input type="number" min="0" max="1000" value="280" id="adjust-min-width"></td>
</tr>
<tr>
<td>maxColumns:</td><td><input type="number" min="0" max="1000" value="5" id="adjust-max-columns"></td>
</tr>
<tr>
<td>dragAndDrop:</td>
<td><input type="checkbox" checked id="adjust-drag-and-drop"></td>
</tr>
<tr>
<td>dropCallback:</td>
<td><textarea id="adjust-drop-callback">function(dragElem, targetElem) {
return true;
}</textarea></td>
</tr>
<tr>
<td>callback:</td>
<td><textarea id="adjust-callback">function(elem, index) {
if (index === 3) {
elem.classList.add('highlight');
} else {
elem.classList.remove('highlight');
}
}</textarea></td>
</tr>
</tbody>
<tfoot>
<tr>
<td><button class="apply-adjustments">Apply</button></td>
<td></td>
</tr>
</tfoot>
</table>
<div class="toggle-widget">
<p>Toggle Adjust Widget</p>
<button>⇕</button>
</div>
</div>
<button class="add-card">Inject a card</button>
<article style="visibility:hidden;">
<section class="flagstone-drag-handle">
<h2>1</h2>
<button class="flagstone-remove">×</button>
<p class="p-animate">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Accusamus ducimus unde amet quam omnis aliquid aliquam culpa, explicabo ut officia illum doloremque debitis, fugiat eos. Hic cupiditate sapiente placeat temporibus.</p>
<button class="toggle-more show-more flagstone-resize-height">Show More</button>
<button class="toggle-more show-less flagstone-resize-height">Show Less</button>
</section>
<section class="flagstone-drag-handle">
<h2>2</h2>
<button class="flagstone-remove">×</button>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Accusamus ducimus unde amet quam omnis aliquid aliquam culpa, explicabo ut officia illum doloremque debitis, fugiat eos. Hic cupiditate sapiente placeat temporibus.</p>
<img src="http://placebear.com/160/160" alt="" style="float:left;width:80px;margin:10px 10px 10px 0;"/>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Accusamus ducimus unde amet quam omnis aliquid aliquam culpa, explicabo ut officia illum doloremque debitis, fugiat eos. Hic cupiditate sapiente placeat temporibus.</p>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Accusamus ducimus unde amet quam omnis aliquid aliquam culpa, explicabo ut officia illum doloremque debitis, fugiat eos. Hic cupiditate sapiente placeat temporibus.</p>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Accusamus ducimus unde amet quam omnis aliquid aliquam culpa, explicabo ut officia illum doloremque debitis, fugiat eos. Hic cupiditate sapiente placeat temporibus.</p>
</section>
<section class="flagstone-drag-handle">
<h2>3</h2>
<button class="flagstone-remove">×</button>
<img src="http://placebear.com/260/80" alt="" id="change-my-source"/>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit.</p>
</section>
<section class="flagstone-drag-handle">
<h2>4</h2>
<button class="flagstone-remove">×</button>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Accusamus ducimus unde amet quam omnis aliquid aliquam culpa, explicabo ut officia illum doloremque debitis, fugiat eos. Lorem ipsum dolor sit amet hic cupiditate sapiente placeat temporibus.</p>
</section>
<section class="flagstone-drag-handle">
<h2>5</h2>
<button class="flagstone-remove">×</button>
<p>Lorem ipsum dolor sit amet. Hic cupiditate sapiente placeat temporibus, placeat temporibus, fugiat eos.</p>
</section>
<section class="flagstone-drag-handle">
<h2>6</h2>
<button class="flagstone-remove">×</button>
<p>Lorem ipsum dolor sit amet. Accusamus ducimus unde amet quam omnis aliquid aliquam culpa, explicabo ut officia illum doloremque debitis, fugiat eos. Hic cupiditate sapiente placeat temporibus.</p>
</section>
<section class="flagstone-drag-handle">
<h2>7</h2>
<button class="flagstone-remove">×</button>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Accusamus ducimus unde amet quam omnis aliquid aliquam culpa, explicabo ut officia illum doloremque debitis, fugiat eos. Hic cupiditate sapiente placeat temporibus. Accusamus ducimus unde amet quam omnis.</p>
</section>
<section class="flagstone-drag-handle">
<h2>8</h2>
<button class="flagstone-remove">×</button>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Accusamus ducimus unde amet quam omnis aliquid aliquam culpa, explicabo ut officia illum doloremque debitis, fugiat eos. Hic cupiditate sapiente placeat temporibus. Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ullam quibusdam placeat dolorum natus voluptatum reiciendis cupiditate, cum veritatis accusamus labore consectetur ab amet, sit commodi laudantium beatae molestiae iste repellendus.</p>
</section>
<section class="flagstone-drag-handle">
<h2>9</h2>
<button class="flagstone-remove">×</button>
<p>Lorem ipsum dolor sit amet.</p>
</section>
<section class="flagstone-drag-handle">
<h2>10</h2>
<button class="flagstone-remove">×</button>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Accusamus ducimus unde amet quam omnis aliquid aliquam culpa, explicabo ut officia illum doloremque debitis, fugiat eos. Hic cupiditate sapiente placeat temporibus.</p>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Accusamus ducimus unde amet quam omnis aliquid aliquam culpa, explicabo ut officia illum doloremque debitis, fugiat eos. Hic cupiditate sapiente placeat temporibus.</p>
</section>
<section class="flagstone-drag-handle">
<h2>11</h2>
<button class="flagstone-remove">×</button>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Accusamus.</p>
</section>
</article>
<!-- <article>
<section>
<h2>1</h2>
<button class="flagstone-remove">×</button>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Accusamus ducimus unde amet quam omnis aliquid aliquam culpa, explicabo ut officia illum doloremque debitis, fugiat eos. Hic cupiditate sapiente placeat temporibus.</p>
</section>
<section>
<h2>2</h2>
<button class="flagstone-remove">×</button>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Accusamus ducimus unde amet quam omnis aliquid aliquam culpa, explicabo ut officia illum doloremque debitis, fugiat eos. Hic cupiditate sapiente placeat temporibus.</p>
<img src="http://placebear.com/160/160" alt="" style="float:left;width:80px;margin:10px 10px 10px 0;"/>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Accusamus ducimus unde amet quam omnis aliquid aliquam culpa, explicabo ut officia illum doloremque debitis, fugiat eos. Hic cupiditate sapiente placeat temporibus.</p>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Accusamus ducimus unde amet quam omnis aliquid aliquam culpa, explicabo ut officia illum doloremque debitis, fugiat eos. Hic cupiditate sapiente placeat temporibus.</p>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Accusamus ducimus unde amet quam omnis aliquid aliquam culpa, explicabo ut officia illum doloremque debitis, fugiat eos. Hic cupiditate sapiente placeat temporibus.</p>
</section>
<section>
<h2>3</h2>
<button class="flagstone-remove">×</button>
<img src="http://placebear.com/260/80" alt="" />
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit.</p>
</section>
<section>
<h2>4</h2>
<button class="flagstone-remove">×</button>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Accusamus ducimus unde amet quam omnis aliquid aliquam culpa, explicabo ut officia illum doloremque debitis, fugiat eos. Lorem ipsum dolor sit amet hic cupiditate sapiente placeat temporibus.</p>
</section>
<section>
<h2>5</h2>
<button class="flagstone-remove">×</button>
<p>Lorem ipsum dolor sit amet. Hic cupiditate sapiente placeat temporibus, placeat temporibus, fugiat eos.</p>
</section>
<section>
<h2>6</h2>
<button class="flagstone-remove">×</button>
<p>Lorem ipsum dolor sit amet. Accusamus ducimus unde amet quam omnis aliquid aliquam culpa, explicabo ut officia illum doloremque debitis, fugiat eos. Hic cupiditate sapiente placeat temporibus.</p>
</section>
<section>
<h2>7</h2>
<button class="flagstone-remove">×</button>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Accusamus ducimus unde amet quam omnis aliquid aliquam culpa, explicabo ut officia illum doloremque debitis, fugiat eos. Hic cupiditate sapiente placeat temporibus. Accusamus ducimus unde amet quam omnis.</p>
</section>
<section>
<h2>8</h2>
<button class="flagstone-remove">×</button>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Accusamus ducimus unde amet quam omnis aliquid aliquam culpa, explicabo ut officia illum doloremque debitis, fugiat eos. Hic cupiditate sapiente placeat temporibus. Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ullam quibusdam placeat dolorum natus voluptatum reiciendis cupiditate, cum veritatis accusamus labore consectetur ab amet, sit commodi laudantium beatae molestiae iste repellendus.</p>
</section>
<section>
<h2>9</h2>
<button class="flagstone-remove">×</button>
<p>Lorem ipsum dolor sit amet.</p>
</section>
<section>
<h2>10</h2>
<button class="flagstone-remove">×</button>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Accusamus ducimus unde amet quam omnis aliquid aliquam culpa, explicabo ut officia illum doloremque debitis, fugiat eos. Hic cupiditate sapiente placeat temporibus.</p>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Accusamus ducimus unde amet quam omnis aliquid aliquam culpa, explicabo ut officia illum doloremque debitis, fugiat eos. Hic cupiditate sapiente placeat temporibus.</p>
</section>
<section>
<h2>11</h2>
<button class="flagstone-remove">×</button>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Accusamus.</p>
</section>
</article> -->
<div style="position:absolute;z-index:9999;top:0;right:0;display:block;width:100px;height:100px;border-radius:50% 0 50% 50%;padding:2px;color:#fff;box-shadow:inset 0 0 15px 0 #000;background:#333;font-family:'Georgia',sans-serif;font-size:14px;text-align:center;"><p style="margin-top:10px;"><span style="display:block;">On</span><a href="https://github.com/depthdev" target="_blank" style="display:block;color:#08f;">Github</a><span style="display:block;">and</span><a href="http://depthdev.com/" target="_blank" style="color:#08f;">Depth</a></p></div>
<script>
// Download plugin from https://github.com/depthdev/flagstonejs
/*
FlagstoneJS v4.0.0
(c) 2015-2018 Depth Development. http://depthdev.com
License: MIT
*/
!function(e,t){"use strict";e.flagstone=function(n,r){function a(n,r){function a(){for(var e=0,t=k.length;e<t;e++)Math.random()<q&&k.splice(e,0,!1)}function o(){L.style.visibility="hidden"}function s(){L.style.visibility="visible"}function i(){var t=[w],n=0,r=O.length;for(M=[];n<r;n++){if(n<w)k[n]?(k[n].style.transform="translate("+(A*n+(n?C*n+E:E))+"px,"+E+"px)",Z&&(k[n].style.height=k[n].style.width),t[n]=O[n]+E,ae(k[n],n),M.push([k[n]])):w>1&&(t[n]=A+E);else{var a=Math.min.apply(null,t),o=t.indexOf(a);k[n]?(k[n].style.transform="translate("+(A*o+(o?C*o+E:E))+"px,"+(a+C)+"px)",Z&&(k[n].style.height=k[n].style.width),t[o]+=O[n]+C,ae(k[n],n),M[o].push(k[n])):w>1&&(t[o]+=A+C)}b=(Math.max.apply(null,t)||O[0]+E)+E,L.style.height=b+"px"}e.setTimeout(s)}function l(t){if(k.length){y=L.offsetWidth,y<T+(E?2*E:0)&&(y=T),D=Math.floor(y/T),w=D>x?x:D,A=y/w-(C*(w-1)+2*E)/w,O=[];for(var n=0,r=k.length;n<r;n++)k[n]&&(k[n].style.width=A+"px",k[n].style.marginTop="0px"),O.push(Z||!k[n]?A:k[n].offsetHeight);y===L.offsetWidth||t?i():l(!0),t||e.setTimeout(function(){l(!0)},W)}}function g(t){if("keydown"!==t.type||13===t.keyCode||32===t.keyCode){for(var n=t.target;n&&!n.classList.contains(B);)n=n.parentElement;L.removeChild(n),e.MutationObserver||!oe&&!se||de()}}function d(t){"keydown"===t.type&&13!==t.keyCode&&32!==t.keyCode||e.setTimeout(l,Q)}function c(t){function n(){for(var t=0,n=M.length,r=0,a=0;t<n&&!g;t++)for(r=0,a=M[t].length;r<a;r++)g&&(i.push(M[t][r]),l.push(e.parseInt(M[t][r].style.marginTop,10)||0)),M[t][r]===o&&(g=!0)}function r(){for(var t=0,n=w,a=[];t<n;t++){var o=M[t][M[t].length-1],s=e.parseInt(o.style.transform.match(/\d+px/)[0],10)+(e.parseInt(o.style.marginTop,10)||0)+o.offsetHeight+E;a.push(s)}var i=Math.max.apply(null,a);L.style.height=i+"px",V=e[($?"request":"cancel")+"AnimationFrame"](r)}function a(){function t(){for(var r=o.offsetHeight+s,g=r-a,d=0;d<n;d++)i[d].style.marginTop=g+l[d]+"px";te=e[(ne?"request":"cancel")+"AnimationFrame"](t)}var n=i.length,a=e.parseInt(i[0].style.transform.match(/\d+px/)[0],10)-C+l[0];ne=!0,te=e.requestAnimationFrame(t),re=e.setTimeout(function(){ne=!1,e.cancelAnimationFrame(te)},U),$=!0,V=e.requestAnimationFrame(r),ee=e.setTimeout(function(){$=!1,e.cancelAnimationFrame(V)},U)}for(var o=t;o&&!o.classList.contains(B);)o=o.parentElement;var s=e.parseInt(o.style.transform.match(/\d+px/)[0],10)+(e.parseInt(o.style.marginTop,10)||0),i=[],l=[],g=!1;return n(),$=!1,e.cancelAnimationFrame(V),e.clearTimeout(ee),ne=!1,e.cancelAnimationFrame(te),e.clearTimeout(re),i.length?void a():($=!0,V=e.requestAnimationFrame(r),void(ee=e.setTimeout(function(){$=!1,e.cancelAnimationFrame(V)},U)))}function m(e){"keydown"===e.type&&13!==e.keyCode&&32!==e.keyCode||c(e.target)}function f(){e.clearTimeout(le),le=e.setTimeout(l,Y)}function v(){e.clearTimeout(ge),ge=e.setTimeout(de)}function u(){e.removeEventListener("resize",f),t.head.removeChild(t.getElementById("flagstone-"+S+"-styles"))}function h(e){e.margin||0===e.margin?(E=e.margin,C=e.margin):(E=e.bedPadding||E,C=e.stonesMargin||C),T=e.minWidth||T,x=e.maxColumns||x,G=e.dragAndDrop===!0||e.dragAndDrop===!1?e.dragAndDrop:G,K=e.dropCallback||K,ae=e.callback||ae,de()}var S=e.flagstone.index,p=r||{},L=n?"string"==typeof n?t.querySelector(n):n:t.getElementsByClassName("flagstone")[0],E=p.margin||0===p.margin?p.margin:p.bedPadding||0===p.bedPadding?p.bedPadding:10,y=0,b=0,T=p.minWidth||280,x=p.maxColumns||5,D=0,w=0,k=[],C=p.margin||0===p.margin?p.margin:p.stonesMargin||0===p.stonesMargin?p.stonesMargin:10,A=y/w-C*(w+1)/w,O=[],M=[],B="flagstone-"+S+"-bed__stone",F=p.flow,z=p.direction?p.direction.toLowerCase():"left",I=p.assignReverseZIndexes,P=p.random,q=p.spaceFrequency||.4,N=p.space,W=p.animationDuration||0,H=p.animationDuration/1e3,R=p.animationTimingFunction||"linear",_=p.heightAnimationDuration||0,X=p.heightAnimationDuration/1e3,j=p.heightAnimationTimingFunction||"linear",Y=p.resizeDelay||0===p.resizeDelay?p.resizeDelay:250,Z=p.square,G=p.dragAndDrop,J=p.dragAndDropAutoDelay,K=p.dropCallback||function(){return!0},Q=p.eventResetDelay||0,U=p.eventResizeHeightDuration||0,V=null,$=!1,ee=null,te=null,ne=!1,re=null,ae=p.callback||function(){},oe=p.watch!==!1,se=p.watchAll,ie=p.watchImages!==!1,le=null,ge=null,de=null,ce={targetElem:null,dragStone:null,targetStone:null,targetStoneOverLeft:0,autoDropTimer:null,autoDrop:function(){ce.targetStone&&ce.targetStone.classList.contains(B)&&(ce.targetStoneOverLeft?ce.dragStone!==ce.targetStone.previousElementSibling&&(ce.targetStone.parentElement.insertBefore(ce.dragStone,ce.targetStone),ce.targetStone.classList.remove("flagstone-left"),ce.targetStone.classList.remove("flagstone-dragover")):ce.dragStone!==ce.targetStone.nextElementSibling&&(ce.targetStone.parentElement.insertBefore(ce.dragStone,ce.targetStone.nextElementSibling),ce.targetStone.classList.remove("flagstone-right"),ce.targetStone.classList.remove("flagstone-dragover")),e.clearTimeout(ce.autoDropTimer),ce.autoDropTimer=e.setTimeout(ce.autoDrop,J))},clear:function(){ce.dragStone&&(ce.dragStone.classList.remove("flagstone-drag"),ce.dragStone=null),ce.targetStone&&(ce.targetStoneOverLeft=0,ce.targetStone.classList.remove("flagstone-dragover"),ce.targetStone.classList.remove("flagstone-left"),ce.targetStone.classList.remove("flagstone-right"),ce.targetStone=null),L.classList.remove("flagstone-dragover")},getTargetElem:function(e){for(ce.targetElem=e.target instanceof HTMLElement?e.target:e.target.parentElement;ce.targetElem&&!ce.targetElem.classList.contains("flagstone-drag-handle");)ce.targetElem=ce.targetElem.parentElement;if(ce.targetElem)for(ce.dragStone=ce.targetElem;ce.dragStone&&!ce.dragStone.classList.contains(B);)ce.dragStone=ce.dragStone.parentElement},mouseDown:function(e){ce.getTargetElem(e)},dragStart:function(e){return!!ce.targetElem&&(ce.dragStone.classList.add("flagstone-drag"),void(e.dataTransfer&&e.dataTransfer.setData("text",this.id)))},touchStart:function(e){ce.getTargetElem(e),ce.dragStart(e)},dragEnter:function(t){t.preventDefault(),t.stopPropagation(),this!==ce.dragStone&&this!==ce.targetStone&&this!==L&&(e.clearTimeout(ce.autoDropTimer),ce.autoDropTimer=e.setTimeout(ce.autoDrop,J))},touchMove:function(e){if(!ce.dragStone)return!1;e.preventDefault(),e.stopPropagation();for(var n=t.elementFromPoint(e.touches[0].clientX,e.touches[0].clientY),r=n;r&&!r.classList.contains(B);)r=r.parentElement;r?(L.classList.remove("flagstone-dragover"),ce.targetStoneOverLeft=r.getBoundingClientRect().left+r.offsetWidth/2>e.touches[0].clientX,ce.targetStone&&ce.targetStone!==r&&(ce.targetStone.classList.remove("flagstone-dragover"),ce.targetStone.classList.remove("flagstone-left"),ce.targetStone.classList.remove("flagstone-right")),ce.targetStone=r,ce.targetStone.classList.contains("flagstone-lock")||(ce.targetStone.classList.add("flagstone-dragover"),ce.targetStoneOverLeft?(ce.targetStone.classList.remove("flagstone-right"),ce.targetStone.classList.add("flagstone-left")):(ce.targetStone.classList.remove("flagstone-left"),ce.targetStone.classList.add("flagstone-right")))):n===L&&(ce.targetStone.classList.remove("flagstone-dragover"),ce.targetStone.classList.remove("flagstone-left"),ce.targetStone.classList.remove("flagstone-right"),L.classList.add("flagstone-dragover"),ce.targetStone=L)},dragOver:function(e){return!!ce.dragStone&&(e.preventDefault(),e.stopPropagation(),e.dataTransfer.dropEffect="move",void(this!==ce.dragStone&&this.classList.contains(B)?(ce.targetStone=this,ce.targetStone.classList.add("flagstone-dragover"),ce.targetStoneOverLeft=this.getBoundingClientRect().left+this.offsetWidth/2>e.clientX,ce.targetStoneOverLeft?(ce.targetStone.classList.remove("flagstone-right"),ce.targetStone.classList.add("flagstone-left")):(ce.targetStone.classList.remove("flagstone-left"),ce.targetStone.classList.add("flagstone-right")),this.classList.remove("flagstone-dragover"),ce.targetStone!==L&&L.classList.remove("flagstone-dragover")):this===L&&this.classList.add("flagstone-dragover")))},dragEnd:function(){ce.clear()},touchEnd:function(){ce.dragStone&&ce.targetStone&&!ce.targetStone.classList.contains("flagstone-lock")&&K(ce.dropStone,ce.targetStone)&&(ce.targetStone===L?L.appendChild(ce.dragStone):ce.targetStoneOverLeft?L.insertBefore(ce.dragStone,ce.targetStone):L.insertBefore(ce.dragStone,ce.targetStone.nextElementSibling)),ce.clear()},dragLeave:function(){ce.targetStone&&(ce.targetStone.classList.remove("flagstone-dragover"),ce.targetStone.classList.remove("flagstone-left"),ce.targetStone.classList.remove("flagstone-right"),L.classList.remove("flagstone-dragover"))},drop:function(t){if(!ce.dragStone)return!1;if(t.stopPropagation(),e.clearTimeout(ce.autoDropTimer),ce.dragStone!==this&&(this.classList.contains(B)||this===L)){if(ce.targetStone=this,ce.targetStone===L){if(!K(ce.dragStone,ce.targetStone))return ce.clear(),!1;ce.targetStone.appendChild(ce.dragStone)}else if(ce.targetStoneOverLeft){if(!K(ce.dragStone,ce.targetStone))return ce.clear(),!1;ce.targetStone.parentElement.insertBefore(ce.dragStone,ce.targetStone)}else{if(!K(ce.dragStone,ce.targetStone.nextElementSibling))return ce.clear(),!1;ce.targetStone.parentElement.insertBefore(ce.dragStone,ce.targetStone.nextElementSibling)}ce.clear(),e.MutationObserver||!oe&&!se||de()}return!1}};return de=function(){k=Array.prototype.slice.call(L.children);for(var t=0,n=k.length;t<n;t++)k[t].classList.add(B),I&&(k[t].style.zIndex=n-t);if(ie)for(var r=L.getElementsByTagName("img"),o=0,s=r.length;o<s;o++)r[o].naturalWidth||(r[o].removeEventListener("load",l),r[o].addEventListener("load",l),r[o].removeEventListener("error",l),r[o].addEventListener("error",l));for(t=0;t<n;t++)k[t].removeAttribute("draggable"),k[t].removeEventListener("mousedown",ce.mouseDown),k[t].removeEventListener("dragstart",ce.dragStart),k[t].removeEventListener("touchstart",ce.touchStart),k[t].removeEventListener("touchmove",ce.touchMove),k[t].removeEventListener("dragover",ce.dragOver),k[t].removeEventListener("dragleave",ce.dragLeave),k[t].removeEventListener("dragend",ce.dragEnd),k[t].removeEventListener("touchend",ce.touchEnd),k[t].removeEventListener("drop",ce.drop),k[t].removeEventListener("touchend",ce.drop),k[t].removeEventListener("dragenter",ce.dragEnter);if(L.removeEventListener("dragover",ce.dragOver),L.removeEventListener("drop",ce.drop),G){for(t=0;t<n;t++)k[t].classList.contains("flagstone-lock")||(k[t].setAttribute("draggable","true"),k[t].addEventListener("mousedown",ce.mouseDown),k[t].addEventListener("dragstart",ce.dragStart),k[t].addEventListener("touchstart",ce.touchStart),k[t].addEventListener("touchmove",ce.touchMove),k[t].addEventListener("dragover",ce.dragOver),k[t].addEventListener("dragleave",ce.dragLeave),k[t].addEventListener("dragend",ce.dragEnd),k[t].addEventListener("touchend",ce.touchEnd),k[t].addEventListener("drop",ce.drop),k[t].addEventListener("touchend",ce.drop),J&&k[t].addEventListener("dragenter",ce.dragEnter),k[t].getElementsByClassName("flagstone-drag-handle").length||k[t].classList.add("flagstone-drag-handle"));L.addEventListener("dragover",ce.dragOver),L.addEventListener("drop",ce.drop)}(P||N)&&(P&&k.sort(function(){return.5-Math.random()}),N&&a());var i=L.getElementsByClassName("flagstone-remove");for(t=0,n=i.length;t<n;t++)i[t].removeEventListener("click",g),i[t].addEventListener("click",g),i[t].removeEventListener("keydown",g),i[t].addEventListener("keydown",g);for(i=L.getElementsByClassName("flagstone-reset"),t=0,n=i.length;t<n;t++)i[t].removeEventListener("click",d),i[t].addEventListener("click",d),i[t].removeEventListener("keydown",d),i[t].addEventListener("keydown",d);for(i=L.getElementsByClassName("flagstone-resize-height"),t=0,n=i.length;t<n;t++)i[t].removeEventListener("click",m),i[t].addEventListener("click",m),i[t].removeEventListener("keydown",m),i[t].addEventListener("keydown",m);l(),e.setTimeout(function(){l(!0)},W)},function(){if(o(),L.classList.add("flagstone-"+S+"-bed"),!t.getElementById("flagstone-"+S+"-styles")){var n=".flagstone-"+S+"-bed{box-sizing:border-box;list-style-type:none;overflow:hidden;position:relative;min-width:"+(T+2*E)+"px;}",r=".flagstone-"+S+"-bed__stone{box-sizing:border-box;position:absolute;top:0px;"+z+":0px;margin:0;}",a=".flagstone-"+S+"-bed__stone{transition:transform "+H+"s "+R+(F?",width "+H+"s "+R:"")+(_?",height "+X+"s "+j:"")+";}",s=n+r+a,i=t.createElement("style");i.type="text/css",i.id="flagstone-"+S+"-styles",i.appendChild(t.createTextNode(s)),t.head.appendChild(i)}if(de(),e.removeEventListener("resize",f),e.addEventListener("resize",f),e.MutationObserver&&(oe||se)){var l=new e.MutationObserver(v);se&&ie?l.observe(L,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["src"]}):l.observe(L,{childList:!0,subtree:se})}}(),{adjust:h,destroy:u,resizeHeight:c,hide:o,reset:f,hardReset:de}}return e.flagstone.index++,new a(n,r)},e.flagstone.index=-1}(window,document);
</script>
@import url('https://fonts.googleapis.com/css?family=Open+Sans');
$white: #fff;
$gray--dark: #5d646e;
$gray: #868080;
$gray--light: #aaa;
$yellow: #ff0;
*,*:before,*:after{box-sizing:border-box;margin:0;padding:0;}
html{background:#777;}
body{font:400 18px/1.4 "Open Sans", sans-serif;margin:0 2vw;background:inherit;min-height:1100px}
h1{margin:10px;padding-top:30px;font-size:48px;color:#aaa;text-shadow:0 0 5px $gray--dark;text-align:center}
h1 a{text-decoration:none;color:inherit;}
.slogan {display:block;font-size:10px;text-shadow: initial;text-transform:uppercase;letter-spacing:8px;text-indent:8px;}
.quick-info {display:block;margin: 10px 0;font-family:sans-serif;font-size:11px;text-shadow:initial;text-align:center;text-transform:uppercase;color:#aaa;}
button{border:none;outline:none;}
p{margin-top:1em;}
.adjust {
position: fixed;
z-index: 100;
top: -290px;
left: 0;
width: 350px;
height: 290px;
border-radius: 0 0 10px 0;
padding: 10px 10px 0 10px;
background-color: $gray--light;
color: $white;
font-size: 12px;
transition: top 0.25s ease;
box-shadow: 4px 4px 4px 0 $gray--dark;
&.active {
top: 0px;
}
.toggle-widget {
padding-top: 10px;
margin-top: 10px;
font-size: 16px;
color: $yellow;
cursor: pointer;
user-select: none;
&:after {
content: "";
display: table;
clear: both;
}
p {
float: left;
margin: 0;
}
button {
float: right;
background: none;
line-height: 1em;
font-size: 18px;
color: inherit;
}
}
table {
table-layout: fixed;
border-collapse: collapse;
}
th {
border-bottom: 1px solid $white;
padding-bottom: 4px;
font-weight: 800;
&:first-of-type {
width: 50%;
}
}
td {
padding-top: 4px;
}
tfoot {
button {
padding: 5px;
background: $yellow;
color: $gray--dark;
cursor: pointer;
&:focus {
box-shadow: 2px 2px 4px 0 #000;
}
}
}
input,
textarea {
color: $gray--dark;
}
textarea {
width: 100%;
height: 33px;
}
}
.add-card {
margin-bottom: 10px;
padding: 5px;
background: $yellow;
color: $gray--dark;
cursor: pointer;
&:focus {
box-shadow: 2px 2px 4px 0 #000;
}
}
article{margin-bottom:100px;background:#aaa;}
article section{overflow-y:auto;padding:15px;background-image:linear-gradient(to bottom right,$gray--dark,$gray);color:#fff;}
img{width:100%;}
iframe{width:100%;height:56.25%;}
.p-animate {
overflow: hidden;
max-height: 40px;
transition: max-height 0.25s ease;
&.active {
max-height: 200px;
& + .show-more {
display: none;
& + .show-less {
display: inline-block;
}
}
}
& + .show-more {
display: inline-block;
& + .show-less {
display: none;
}
}
}
.toggle-more {
padding: 5px;
background: $yellow;
color: $gray--dark;
cursor: pointer;
&:focus {
box-shadow: 2px 2px 4px 0 #000;
}
}
.highlight{
background: $yellow;
color: $gray--dark;
}
.flagstone-remove {
position: absolute;
top: 0;
right: 10px;
margin: 0;
opacity: 0.25;
padding: 0;
background: none;
cursor: pointer;
font-size: 24px;
&:focus,
&:hover {
opacity: 1;
}
}
.flagstone-0-bed.flagstone-dragover {
box-shadow: inset 0 0 4px 4px $yellow;
}
.flagstone-drag {
filter: grayscale(1) blur(4px);
opacity: 0.25;
}
.flagstone-left {
box-shadow: -8px 0 4px -4px $yellow;
}
.flagstone-right {
box-shadow: 8px 0 4px -4px $yellow;
}
// Full documentation: https://github.com/depthdev/flagstonejs
const fs = flagstone(document.getElementsByTagName('article')[0], {
//bedPadding: 10, // The padding around the area edge
//stonesMargin: 10, // Margin between stones in pixels (as an int)
margin: 10, // This overrides bedPadding & stonesMargin and is equivalent to setting them both to this value
minWidth: 280, // Minimum width you want an element to be in pixels (as an int)
maxColumns: 5, // Maximum number of columns to display (as an int)
flow: true, // Allows stone widths to flow during a resize event
direction: 'left', // Alternative is "right"; the default is "left"; and for top to bottom, use CSS's built in Columns or Flexbox
assignReverseZIndexes: false,
random: false, // Display stones in a random order; the default is false (as a boolean)
square: false, // Makes each flagstone square; default is false
space: false, // Spaces out stones randomly (as a boolean)
spaceFrequency: 0.4, // Adjusts the frequency of the amount of spaces (as a float 0.0 - 1.0); default is 0.4
animationDuration: 1000, // Animation duration (milliseconds as an int); default is 0
animationTimingFunction: 'ease', // CSS animation timing function as a string
heightAnimationDuration: 2500,
heightAnimationTimingFunction: 'ease',
resizeDelay: 250, // Delay to run resize/reset function after resizing the window in milliseconds (as an int); default is 250
dragAndDrop: true,
dragAndDropAutoDelay: 1000,
dropCallback: function(dragElem, targetElem) {
// console.log(dragElem);
// console.log(targetElem);
return true;
},
eventResetDelay: 250,
eventResizeHeightDuration: 250,
callback: function(elem, index) { // Warning! This gets called every soft reset, so if you're attaching listeners, you'll need to remove the listeners first!
if (index === 3) {
elem.classList.add('highlight');
} else {
elem.classList.remove('highlight');
}
}, // Callback function for each element with index and element arguments
watch: true,
watchAll: true,
watchImages: true
});
/* DEMO-ONLY FUNCTIONS */
function adjust() {
const $ = function(s){return document.getElementById(s);};
fs.adjust({
//margin: 10,
bedPadding: window.parseInt($('adjust-bed-padding').value,10),
stonesMargin: window.parseInt($('adjust-stones-margin').value,10),
minWidth: window.parseInt($('adjust-min-width').value,10),
maxColumns: window.parseInt($('adjust-max-columns').value,10),
dragAndDrop: $('adjust-drag-and-drop').checked,
dropCallback: window.eval('(' + $('adjust-drop-callback').value + ')'),
callback: window.eval('(' + $('adjust-callback').value + ')')
});
}
function toggleMore(e) {
const p = e.target.parentElement.getElementsByClassName('p-animate')[0];
if (p.classList.contains('active')) {
p.classList.remove('active');
} else {
p.classList.add('active');
}
}
function toggleWidget(e) {
const container = e.currentTarget.parentElement;
if (container.classList.contains('active')) {
container.classList.remove('active');
} else {
container.classList.add('active');
}
}
function addCard() {
const section = document.createElement('section');
section.classList.add('flagstone-drag-handle');
section.innerHTML = '<h2>New Card</h2><button class="flagstone-remove">×</button><p>Lorem ipsum dolor sit amet. Hic cupiditate sapiente placeat temporibus, placeat temporibus, fugiat eos.</p><p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Velit tempora itaque maxime, enim, nam quas nobis voluptate, minus ex adipisci aperiam provident sequi soluta. Praesentium et, placeat porro dolorum voluptate.</p>';
document.getElementsByTagName('article')[0].appendChild(section);
}
Array.prototype.slice.call(document.getElementsByClassName('toggle-more')).forEach(function(e) {
e.addEventListener('click', toggleMore);
});
document.getElementsByClassName('toggle-widget')[0].addEventListener('click', toggleWidget);
document.getElementsByClassName('apply-adjustments')[0].addEventListener('click', adjust);
document.getElementsByClassName('add-card')[0].addEventListener('click', addCard);
window.setTimeout(function() {
document.getElementById('change-my-source').src = 'http://placebear.com/400/400';
}, 3000);
Also see: Tab Triggers