outline on only one border

前端 未结 7 863
独厮守ぢ
独厮守ぢ 2020-12-04 14:23

How to apply an inset border into an HTML element, but just only on one side of it. Until now, I\'ve been using an image to do that (GIF/PNG) that I would

7条回答
  •  悲&欢浪女
    2020-12-04 14:38

    I like to give my input field a border, remove the outline on focus, and "outline" the border instead:

    input {
      border: 1px solid grey;
    
      &:focus {
        outline: none;
        border-left: 1px solid violet;
      }
     }
    

    You can also do it with a transparent border:

    input {
      border: 1px solid transparent;
    
      &:focus {
        outline: none;
        border-left: 1px solid violet;
      }
     }
    

提交回复
热议问题