Placeholder for contenteditable div

后端 未结 12 1569
栀梦
栀梦 2020-12-12 23:18

I have the following: FIDDLE

The placeholder works fine and dandy until you type something, ctrl + A, and delete. If you do that, th

12条回答
  •  无人及你
    2020-12-12 23:58

    I've created a live demo: "Placeholder for content-editable divs", by HTML & CSS.
    Also, Codepen: https://codepen.io/fritx/pen/NZpbqW
    Ref: https://github.com/fritx/vue-at/issues/39#issuecomment-504412421

    .editor {
      border: solid 1px gray;
      width: 300px;
      height: 100px;
      padding: 6px;
      overflow: scroll;
    }
    [contenteditable][placeholder]:empty:before {
      content: attr(placeholder);
      position: absolute;
      color: gray;
      background-color: transparent;
    }
    
    

提交回复
热议问题