Input type color styling

后端 未结 4 1984
梦谈多话
梦谈多话 2021-02-14 06:33

I have a small question, since I\'m not too good at CSS i want to know if there any way I can recreate such a nice input[type=color] element\'s style? I mean not everything on t

4条回答
  •  梦毁少年i
    2021-02-14 06:49

    $(document).ready(function(){
      $('input').change(function(){
       var color = $(this).val();
       $('.color-code').html(color);
       $('.color').css({'background':color})
     })
    })
    .color-picker {
      position: relative;
      width: 100px;
      height: 30px;
      display: block;
    }
    
    .color-code {
      position: absolute;
      top: 0;
      left: 0;
      background: #fff;
      width: 70px;
      height: 30px;
      line-height: 30px;
      text-align: center;
    }
    
    .color {
      position: absolute;
      top: 0;
      right: 0;
      width: 30px;
      height: 30px;
      border-radius: 100%;
    }
    
    
    You want to did this with jquery

提交回复
热议问题