How do I remove the border around a focused contenteditable pre?

前端 未结 2 926
耶瑟儿~
耶瑟儿~ 2021-01-30 12:35

When I set a pre element to contenteditable and put focus in it for editing, it receives a dotted border around it that doesn\'t look very nice. The border isn\'t there when foc

相关标签:
2条回答
  • 2021-01-30 12:49

    Set the outline property to 0px solid transparent;. You might have to set it on the :focus state as well, for example:

    [contenteditable]:focus {
        outline: 0px solid transparent;
    }
    
    0 讨论(0)
  • 2021-01-30 13:05

    You can also add the :read-write pseudo-class to style elements that are editable.

    For instance (jsFiddle):

    .element:read-write:focus {
         outline: none;
    }
    

    Read more here on codrops.

    The :read-write pseudo-class selector is supported in Chrome, Safari, and Opera 14+, and on iOS. It is supported with the -moz- prefix in Firefox in the form :-moz-read-write. The :read-write selector is not supported in Internet Explorer and on Android.

    0 讨论(0)
提交回复
热议问题