Want to create a simple image brightness control slider

后端 未结 4 601
轻奢々
轻奢々 2021-01-06 09:54

I wanted to implement a slider control that changes the brightness of the image, much like the one shown at this link :

http://camanjs.com/examples/

I am fa

4条回答
  •  既然无缘
    2021-01-06 10:10

    To read full implementation check this website How to Create an Image Brightness Control Slider

    rangeInput = document.getElementById('range');
    
    container = document.getElementsByClassName('container')[0];
    
    rangeInput.addEventListener("mousemove",function(){
    container.style.filter = "brightness(" + rangeInput.value + "%)";
    });
    *{
      margin: 0;
      padding: 0;
      box-sizing: border-box;
    }
    
    .container{
      background: url(https://codingdebugging.com/wp-content/uploads/2020/07/include-how-to-create-an-image-brightness-control-slider.jpg) no-repeat center;
      min-height: 100vh;
      background-size: cover;
      display: flex;
      align-items: center;
      justify-content: center;
    }
    
    .brightness-box{
      width: 400px;
      height: 60px;
      background: #f9f9f9;
      border-radius: 8px;
      padding: 0 20px;
      display: flex;
      align-items: center;
      justify-content: space-between;
    }
    
    .brightness-box i{
      margin: 0 10px;
    }
    
    #range{
      width: 100%;
      -webkit-appearance: none;
      background: #0a85ff;
      height: 3px;
      outline: none;
    }
    
    #range::-webkit-slider-thumb{
      -webkit-appearance: none;
      width: 22px;
      height: 22px;
      background: #333;
      border-radius: 50%;
      cursor: pointer;
    }
    
    
    
      Brightness Control - Coding Debugging
    
        
        
    
    
    
    
      

提交回复
热议问题