Changing the highlight color when selecting text in an HTML text input

后端 未结 10 1079
有刺的猬
有刺的猬 2020-11-30 00:07

I\'ve been looking for this throughout the web and can\'t even find anyone else even asking this, let alone a solution...

Is there a way to change the color of the h

10条回答
  •  挽巷
    挽巷 (楼主)
    2020-11-30 00:49

    It seems like when you define the border inside of a focus pseudo element style declaration it uses that instead of the normal blue border. Using that you can define a style that is exactly the same as the element border.

    input:focus, textarea:focus {
        border:1px solid gray;
    }
    
    #textarea  {
      position:absolute;
      top:10px;
      left:10px;
      right:10px;
      width:calc(100% - 20px);
      height:160px;
      display:inline-block;
      margin-top:-0.2em;
    }

    Here is a modified border style:

    input:focus, textarea:focus {
        border:2px dotted red;
    }
    
    #textarea  {
      position:absolute;
      top:10px;
      left:10px;
      right:10px;
      width:calc(100% - 20px);
      height:160px;
      display:inline-block;
      margin-top:-0.2em;
    }

提交回复
热议问题