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. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ add another resource


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


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.



Go PRO Window blinds lowered to protect code. Code Editor with window blinds (raised) and a light blub turned on.

Keep it secret; keep it safe.

Private Pens are hidden everywhere on CodePen, except to you. You can still share them and other people can see them, they just can't find them through searching or browsing.

Upgrade to PRO


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.

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.


Make Template?

Templates are Pens that can be used to start other Pens quickly from the create menu. The new Pen will copy all the code and settings from the template and make a new Pen (that is not a fork). You can view all of your templates, or learn more in the documentation.

Template URL

Any Pen can act as a template (even if you don't flip the toggle above) with a special URL you can use yourself or share with others. Here's this Pen's template URL:


Screenshot or Custom Thumbnail

Screenshots of Pens are shown in mobile browsers, RSS feeds, to users who chose images instead of iframes, and in social media sharing.

This Pen is using the default Screenshot, generated by CodePen. Upgrade to PRO to upload your own thumbnail that will be displayed on previews of this pen throughout the site and when sharing to social media.

Upgrade to PRO


<script src=""></script>
<script src=""></script>
<script src=""></script>
    <link rel="stylesheet" href="" />
    <script src=""></script>
        $(function() {
            $( "#tabs" ).tabs();
            $( "#slider" ).slider();

        #slider_container {
            max-width: 100px;
            margin-left: 20px;


<div id="tabs">
        <li><a href="#tabs-1">Scenario 1</a></li>
        <li><a href="#tabs-2">Scenario 2</a></li>
    <div id="tabs-1">
        <b>Steps to recreate 'jumping' behavior:</b>
            <li>Drag the grey slider all the way to the right</li>
            <li>Drag the blue rect to a new position, diagonally (so you can see the 'jumping')</li>
            <li>When you release the mouse, the blue rect will jump to the new x, but the new y will not
                be updated</li>
            <li>Scrub the timer slider a bit and it's all fine again</li>
    <div id="tabs-2">
        <b>Steps to reset this jumping behavior:</b>
            <li>Click the 'Single Reseek' button</li>
            <li>Drag the blue rect to a new position</li>
            <li>Works fine now</li>

<button onclick='startAnim()'>Play</button>
<button onclick='refreshAll()'>Reset</button>
<button id="btnReseekRedraw" onclick='toggleReseekRedraw()'>Single Reseek</button><br><br>
<div id="slider_container">
    <div id="slider"></div><br>

<div id='kinetic_container'></div>





                var bReseekRedraw = true;
    var stage = new Kinetic.Stage({ container:'kinetic_container', width:1250, height:500 });
    var layer = new Kinetic.Layer();

    var startPos = { x:100, y:50 };
    var endPos = { x:300, y:100 };

    var rect = new Kinetic.Rect({
        x:startPos.x, y:startPos.y, width: 50, height:50, draggable:true, fill: '#009dec'
    rect.on('dragend', function() {


    var t1;
    var aTween;
    var bTween;

    function startApp() {
        t1 = new TimelineMax({paused: true, onUpdate: stageUpdate, onUpdateScope: stage});
    function getDuration() {
        return $("#slider").slider("value");

    function updateEndPos() {
        try {
            aTween.kill(); bTween.kill();
            t1.remove(aTween); t1.remove(bTween);
        } catch (e) {


        endPos.x = rect.getX();
        endPos.y = rect.getY();

        var tTime = 0;

        aTween = TweenMax.fromTo(rect, getDuration(), {setX:startPos.x}, {setX:endPos.x}, tTime);
        t1.add(aTween, tTime);
        if (bReseekRedraw) {

        bTween = TweenMax.fromTo(rect, getDuration(), {setY:startPos.y}, {setY:endPos.y}, tTime);
        t1.add(bTween, tTime);



    function startAnim () {;

    function stageUpdate () {
        $("#slider").slider("value", t1.time());

    function refreshAll() {;
        $("#slider").slider("value", t1.time());
        endPos.x = 0; endPos.y = 0;
        rect.setX(startPos.x); rect.setY(startPos.y);


    function toggleReseekRedraw() {
        bReseekRedraw = !bReseekRedraw;
        if (bReseekRedraw) {
            $('#btnReseekRedraw').html('Single Reseek');
        } else {
            $('#btnReseekRedraw').html('Reseek after each update');


        slide: function (event, ui) {

What did the HTML say to the CSS? I like your style.