Pen Settings



CSS Base

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

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.


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.


                <!-- Use preprocessors via the lang attribute! e.g. <template lang="pug"> -->

    export default {
        data () {
            return {
                left: 0,
                top: 0,
                offsetX: 0,
                offsetY: 0,
                width: 100,
                height: 100
        computed: {
            boxStyle () {
                return {
                    left: this.left + 'px',
                    top: + 'px',
                    width: this.width + 'px',
                    height: this.height + 'px'
        mounted () {
            const resizeObserver = new ResizeObserver(entries => {
                console.log('Size changed')
        methods: {
            dragStart (e) {
                // this.dragStartIndex = index
                const { clientX, clientY } = e
                const { offsetLeft, offsetTop } =
                this.offsetX = offsetLeft - clientX
                this.offset = offsetTop - clientY
                e.dataTransfer.effectAllowed = 'move'
                e.dataTransfer.setData('text/plain', null)
            drag (e) {
                // 实时更新,等效于mousemove
                // 需要调整位置一个是
                //      处理 offsetX, offsetY(鼠标的位置)
                //      或者设置 e.dataTransfer.setDragImage(this.$el, offsetX, offsetY)
                // this.moveBox(e)
            moveBox (e) {
                const { clientX, clientY } = e
                this.left = clientX + this.offsetX
       = clientY + this.offsetY
                this.$emit('dragend', this.left,
            dragend (e) {

  width: 100px;
  height: 100px;
  border: 1px solid #ccc;
  position: absolute;
  left: 0;
  resize: both;
  overflow: auto;