Is it possible to add placeholder in div tag

前端 未结 4 1254
南方客
南方客 2020-12-04 12:26

I would like to display some text to the user when my div element is empty.

I have tried adding a placeholder attribute to my div but the t

4条回答
  •  长情又很酷
    2020-12-04 12:43

    i have already answered to such a question here with this test : http://codepen.io/gcyrillus/pen/hzLIE

    div:empty:before {
      content:attr(data-placeholder);
      color:gray
    }
    

    see If editable div have no text than set placeholder

提交回复
热议问题