Pen Settings

HTML

CSS

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

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

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.

HTML

              
                <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">

<div id="app">
  <h3>크기를 조절해 보세요!</h3>
  <div ref="textBox" 
       class="text-box">
    <div ref="textBoxInner" 
         class="text-box__inner">
      <div ref="text" 
           class="text-box__text">
        Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
      </div>
    </div>
    <div v-show="isOverflow"
         v-cloak
         class="text-box__overflow-ellipsis"
         @click="unfoldDown">
      <i class="material-icons">more_horiz</i>
    </div>
  </div>
</div>
              
            
!

CSS

              
                body {
  padding: 30px;
}
[v-cloak] {
  display: none;
}

h3 {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 6px;
}
.text-box {
  width: 550px;
  height: 280px;
  padding: 20px;
  border: 4px solid;
  box-sizing: border-box;
  position: relative;
  &::after {
    content: "";
    display: block;
    position: absolute;
    bottom: 0;
    right: 0;
    width: 0;
    height: 0;
    border-width: 7px;
    border-style: solid;
    border-top-color: transparent;
    border-left-color: transparent;
  }
  &__inner {
    width: 100%;
    height: 100%;
    overflow: hidden;
  }
  &__text {
    font-size: 20px;
  }
  &__overflow-ellipsis {
    width: 40px;
    height: 16px;
    border: 4px solid;
    border-radius: 4px;
    background: white;
    position: absolute;
    bottom: -14px;
    left: 0;
    right: 0;
    margin: auto;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    i {
      font-size: 30px;
      animation: twinkle 1s infinite alternate;
    }
  }
}

@keyframes twinkle {
  0% {
    opaicty: 1;
  }
  100% {
    opacity: .2;
  }
}
              
            
!

JS

              
                // In general, you need polyfill,
// The recommended module is 'https://github.com/juggle/resize-observer'.

// import ResizeObserver from '@juggle/resize-observer'

new Vue({
  el: '#app',
  data () {
    return {
      isOverflow: false
    }
  },
  mounted () {
    this.initInteractTextBox()
    this.observeTextBoxSize()
  },
  methods: {
    observeTextBoxSize () {
      const ro = new ResizeObserver(entries => {
        const { width, height } = entries[0].contentRect
        
        if (
          // 일반적인 경우.
          (entries[1] && height < entries[1].contentRect.height)
          // $refs.textBox의 높이만 변경될 경우 $refs.text의 크기는 변하지 않기 때문에 entries[1] is undefined,
          // getBoundingClientRect의 Reflow를 최소화.
          || (height < this.$refs.text.getBoundingClientRect().height)
        ) {
          this.isOverflow = true
        } else {
          this.isOverflow = false
        }
      })
      
      ro.observe(this.$refs.textBoxInner)
      ro.observe(this.$refs.text)
    },
    initInteractTextBox () {
      // https://interactjs.io/docs/
      interact(this.$refs.textBox)
        .resizable({
          edges: {
            right: true,
            bottom: true
          }
        })
        .on('resizemove', event => {
          event.target.style.width = `${event.rect.width}px`
          event.target.style.height = `${event.rect.height}px`
        })
    },
    unfoldDown () {
      this.$refs.textBox.style.height = `${this.$refs.text.getBoundingClientRect().height + 48}px` // 48 is $refs.textBox의 Border-box(padding + border) 크기.
    }
  }
})
              
            
!
999px

Console