Pen Settings

HTML

CSS

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.

+ 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

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.

HTML

              
                <div class='cssBox box'>css effect</div>
<div class='gsapBox1 box'>wrong(gsap)</div>
<div class='gsapBox2 box'>right(gsap)</div>
<div class="gsapBox3 box">
  <div class="border"></div>
</div>
              
            
!

CSS

              
                .box{
  position:absolute;
  top:0;
  left:0px;
  width:100px;
  height:100px;
  color:#fff;
  text-align:center;
  line-height:100px;
}

.cssBox{
  background:#1caef2;
}

.move{
/*   animation: move 4s linear both; */
}

@keyframes move{
  25%{
    left: 100px;
  }
  50%{
    left:200px;
    width:200px;
  }
  100%{
    top:200px;
  }
}

.gsapBox1{
  transform: translateX(400px);
  background:#ce4680;
}

.gsapBox2{
  transform: translateX(800px);
  background:#39c55f;
}

.gsapBox3{
  transform: translateX(0);
  background:#39c55f;
}

.border{
  position:absolute;
  width:2rem;
  height:100%;
  box-sizing:border-box;
  border:0.5rem solid red;
}
              
            
!

JS

              
                var $cssBox =  document.querySelector('.cssBox'),
    $gsapBox1 =  document.querySelector('.gsapBox1'),
    $gsapBox2 =  document.querySelector('.gsapBox2'),
    $border =  document.querySelector('.border'),
    tl1 = new TimelineLite(),
    tl2 = new TimelineLite();


$cssBox.className = 'cssBox box move';
//I hope I can set keyframes like css3 animation ,in which the intermediate values will be auto-completed, but it doesn't work as I supposed.For example, the 'width' only animate in the second tween.
TweenLite.defaultEase = Linear.easeNone;
$gsapBox2.onclick = function(){
    tl1.to($border, 1, {width:'4rem',border:'2rem solid red'});
}

// tl1.to($gsapBox1, 1, {left:100})
//   .to($gsapBox1, 1, {left:200, width:200,grayscale:1})
//   .to($gsapBox1, 2, {top:200})

//To achieve the desired effect, I must set many tweens for different properties, which is very complex.
// tl2.to($gsapBox2, 1, {x:100})
//   .to($gsapBox2, 1, {left:200})
//   .to($gsapBox2, 2, {left:0})//this is the default value,but I have to set it manually
//   .to($gsapBox2, 2, {width:200},0)
//   .to($gsapBox2, 2, {width:100},2)
//   .to($gsapBox2, 4, {top:200},0)

// alert($gsapBox2[0]._gsTransform.x)

//in this way,if I have more keyframes and more properies,I have to set a more complex timelineLite with many tweens.
//Is there any better way to do the keyframes animation? Thank you very much.



              
            
!
999px

Console