Clicking outside a contenteditable div stills give focus to it?

后端 未结 5 1248
独厮守ぢ
独厮守ぢ 2020-12-14 15:52

For some reason I need to use contenteditable div instead of normal text input for inputting text. (for some javascript library) It works fine until I found that when I set

5条回答
  •  不知归路
    2020-12-14 16:31

    If it's not needed to use display: inline-block, I would recommend using float. Here is the example.

    Based on your example, the new CSS would be:

    div.text-input {
      display: block;
      background-color: black;
      color: white;
      width: 300px;
      float: left;
      margin-right: 10px;
    }
    div.unrelated {
      clear: both;
    }
    

提交回复
热议问题