Pen Settings



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


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.


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.


                <div id="app">
    <button @click="shuffle">shuffle</button>
    <div class="box">
      <div class="cell" ref="cell" v-for="(item) in list" :key="item">{{ item }}</div>


                .box {
  width: 500px;

.cell {
  box-sizing: border-box;
  float: left;
  width: 50px;
  height: 50px;
  line-height: 48px;
  text-align: center;
  border: 1px solid #000;


                function shuffle(array) {
  let len = array.length;
  for (let i = len - 1; i > 0; i--) {
    let j = Math.floor(Math.random() * (i + 1));
    [array[i], array[j]] = [array[j], array[i]];
  return array.slice()

function getPositionList(domList) {
  return => {
    const {left, top} = dom.getBoundingClientRect()
    return {left, top}

var vm = new Vue({
  data() {
    let list = []
    for (let i = 0; i < 100; ++i) {
    return {

  methods: {
    shuffle() {
      this.list = shuffle(this.list)

      const cellList = this.$refs.cell.slice() // 保存快照

      const originPositions = getPositionList(cellList)

      this.$nextTick(() => {
        // 需要保证变化前后的DOM节点一致,因此v-for的key不能使用index
        const currentPositions = getPositionList(cellList)

        cellList.forEach((cell, index) => {
          let cur = currentPositions[index]
          let origin = originPositions[index]

          const invert = {
            left: origin.left - cur.left,
            top: -,

          const keyframes = [
              transform: `translate(${invert.left}px, ${}px)`,
            {transform: "translate(0)"},

          const options = {
            duration: 3000,
            easing: "linear",

          cell.animate(keyframes, options)