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.

+ add another resource


Babel is required to process package imports. If you need a different preprocessor remove all packages first.

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


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.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.


              <!-- example6 多物体同时运动 -->
    <div class="example" id="example6">
        <div id="div6">


               * {
   margin: 0;
   padding: 0;
 #div6 li {
   border: 2px solid black;
   list-style: none;
   position: relative;
   background-color: yellow;
   width: 150px;
   height: 50px;
   margin-bottom: 10px;
   opacity: 1;


              window.onload = function() {
  var oDiv6 = document.getElementById('div6');
  var oLiList6 = oDiv6.getElementsByTagName('li');

  var json = {'width':200,'height':150,'opacity':20};
  var json_r = {'opacity':100,'height':50,'width':150,};
  for (var i = 0; i < oLiList6.length; i++) {
    oLiList6[i].onmouseover = function(){
    oLiList6[i].onmouseout = function(){

var timer,oAttr;
function startAnimate(obj, json, fn) {
  // 简单的深拷贝一份 json 数据
  var jsonTmp = JSON.parse(JSON.stringify(json));
  obj.timer = setInterval(function() {
    // 添加不同的动画效果 attr 即每个属性,json[attr] 即属性值
    for (var attr in json) {
    // 判断属性是否为透明度,若为透明度不需要进行字符串转型

    if (attr == 'opacity') {
      // 此处未考虑 IE9 之前的兼容
      oAttr = getStyle(obj,attr) * 100;
    } else {
      oAttr = parseInt(getStyle(obj, attr));
    var speed = (json[attr] - oAttr) * 0.1;
    speed = speed > 0 ? Math.ceil(speed) : Math.floor(speed);
    if (json[attr] == oAttr) {
      delete jsonTmp[attr];
      var jsonLenght = 0;
      for (var attr in jsonTmp) {
      if (jsonLenght == 0) {
        if (fn) fn();
    } else {
      // 如果属性为透明度,需要和其他属性区别
      if (attr == 'opacity') { = (oAttr + speed)/100;
      } else {[attr] = oAttr + speed + 'px';
}, 30);

function getStyle(obj, attr) {
  if (obj.currentStyle) {
    // IE 浏览器
    return obj.currentStyle[attr];
  } else {
    // Firefox、Chrome
    return getComputedStyle(obj, false)[attr];