Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <input type="checkbox" id="switch">
<div class="container">
  <span class="inside">
    <span class="item header">
      <label for="switch">
          <div class="names">
            <span class="light">🌞</span>
            <span class="dark">🌙</span>
          </div>
      </label>
      <p>Change color : </p>
      <p>
        <form action=""><input type="color" id="html5colorpicker" value="#181E29"></form>
        <span class="html5colorpicker"></span>
      </p>
    </span>
    <div class="item">
      <p>90% <span>Brightness</span></p>
      <p></p>
    </div>
   <div class="item">
      <p>80% <span>Brightness</span></p>
      <p></p>
    </div>
   <div class="item">
      <p>70% <span>Brightness</span></p>
      <p></p>
    </div>
   <div class="item">
      <p>60% <span>Brightness</span></p>
      <p></p>
    </div>
   <div class="item">
      <p>50% <span>Brightness</span></p>
      <p></p>
    </div>
   <div class="item">
      <p>40% <span>Brightness</span></p>
      <p></p>
    </div>
   <div class="item">
      <p>30% <span>Brightness</span></p>
      <p></p>
    </div>
   <div class="item">
      <p>20% <span>Brightness</span></p>
      <p></p>
    </div>
   <div class="item">
      <p>10% <span>Brightness</span></p>
      <p></p>
    </div>
    <div class="item">
      <p>0% - Full color</p>
      <p></p>
    </div>
    <div class="info">Click to copy</div>
  </div>
</div>
<input id="linkToCopy" value="" />  
<div class="notify"><span id="notifyType" class=""></span></div>

              
            
!

CSS

              
                @import url('https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,500;1,700&display=swap');
html {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: 'Roboto';
  font-weight: normal;
  font-size: 15px;
  webkit-font-smoothing: antialiased;
  width: 100%;
  height: 100%;
}

body{
  margin:0;
  padding: 0;
  position: fixed;
  width: 100%;
  height: 100%;
  transition: background-color .25s ease;
}

#html5colorpicker{
   width: calc(100% - 8px);
   height: 100%;
   border: 1px solid #fff;
   border-radius: 10px;
   -webkit-appearance: none;
   opacity: 0;
   top: 0;
   right: 0;
   z-index: 2;
   position: absolute;
   cursor: pointer;
}

.html5colorpicker{
  display: inline-block;
  width: 100px;
  height: 20px;
  position: absolute;
  right: 1em;
  display: block;
  border: 2px solid #fff;
  border-radius: 10px;
  top: 10px;
  cursor: pointer;
}

.inside {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  box-shadow: -1px 13px 25px -5px rgba(0,0,0,0.13);
  background: #fff;
  border-radius: 10px 0 10px 10px;
  border: 4px solid #fff;
}

.item {
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  width: 250px;
  line-height: 1;
  padding-right: 20px;
  padding-left: 20px;
  cursor: pointer;
  
  p:last-child{
    text-transform: uppercase;
  }
  
  &:first-child p:last-child{
    text-align: center;
    width: 95px;
  }
}

.header {
  border-radius: 10px 0px 0px 0px;
  color: white;
  position: relative;
  
  p:nth-child(2){
    font-size: 20px;
    line-height: 4px;
    font-weight: bold;
    font-style: italic;
  }
}

.item {
  transition-timing-function: cubic-bezier(0.42, 0, 1, 1);
  transition-duration: .1s;
  
  p{
    text-shadow: -1px -1px 0 rgba(0,0,0,1), 1px -1px 0 rgba(0,0,0,1), -1px 1px 0 rgba(0,0,0,1), 1px 1px 0 rgba(0,0,0,1);
    color: white;
  }
  
  &:nth-child(11){
      border-radius: 0px 0px 10px 10px;
  }
}

.item:not(:first-child):hover {
  border-radius: 2px 2px 2px 2px;
  transform: scale(1.1);
  box-shadow: -1px 13px 25px -5px rgba(0,0,0,0.13);
  transition-timing-function: cubic-bezier(0.42, 0, 1, 1);
  transition-duration: .1s;
}

#linkToCopy{
  position: absolute; z-index: -999; opacity: 0;
}

.notify{  
  position:absolute;
  top:0px;
  width:100%;
  height:0;  
  box-sizing:border-box;
  color:white;  
  text-align:center;
  background:rgba(0,0,0,.6);
  overflow:hidden;
  box-sizing:border-box;
  transition:height .2s;
}

#notifyType:before{
  display:block;
  margin-top:15px; 
}

.active{  
  height:50px;
}

.success:before{
  Content:"Copied into clipboard !";
}

.info{
  font-style: italic;
  text-align: center;
  position: absolute;
  bottom: -30px;
  left: 50%;
  transform: translateX(-50%);
  text-shadow: -1px -1px 0 black, 1px -1px 0 black, -1px 1px 0 black, 1px 1px 0 black;
  color: white;
  cursor: default;
}

#switch{
  position: absolute;
  opacity: 0;
}

label {
  width: 100px;
  background-color: #fff;
  border-radius: 0 10px 10px 0;
  cursor: pointer;
  position: absolute;
  right: 0;
  top: -4px;
  transform: translateX(100%);
  color: #fff;
  border: 4px solid #fff;
  height: 44px;
}

.names {
  font-size: 25px;
  font-weight: bolder;
  width: 100px;
  position: absolute;
  user-select: none;
  line-height: 42px;
}

.light,
.dark{
  width: 50%;
  text-align: center;
  padding: 0 6px;
  transition: opacity .25s ease;
}

.dark {
  opacity: .3;
}

[type="checkbox"]:checked + .container .dark{
  opacity: 1;
}
[type="checkbox"]:checked + .container .light{
  opacity: .3;
}
              
            
!

JS

              
                $(document).ready(function(){
  var mode = "light";
  $('.item:not(:first-child)').hover(function(){
    let color = $(this).css('background-color');
    $('body').css("background", color);
  });
  
  $('#switch').change(function(){
    mode = mode == "light" ? "dark" : "light";
    updateColors();
  });

  $('#html5colorpicker').change(function(){
    updateColors();
  });
  
  function updateColors(el){
    let color = $('#html5colorpicker').val();
    var lvl = [0, 90, 80, 70, 60, 50, 40, 30, 20, 10, 0];
    var i = 0;
    $('.item').each(function(){
      $(this).css('background-color', ChangeColor(color, lvl[i]));
      $(this).find('p:last-child').text(ChangeColor(color, lvl[i]));
      i++;
    })
    $('body').css('background', 'linear-gradient(90deg, '+ color +' 0%, '+ ChangeColor(color, 30) +' 100%)');
    if(mode == "dark"){
      $('.item:not(:first-child) p:first-child span').text('Darkness');
    }else{
      $('.item:not(:first-child) p:first-child span').text('Brightness');
    }
  }

  function ChangeColor(color, percent) {
    if(mode == "dark"){
      percent = '-' + percent;
    }
    var num = parseInt(color.replace("#",""),16),
    amt = Math.round(2.55 * percent),
    R = (num >> 16) + amt,
    B = (num >> 8 & 0x00FF) + amt,
    G = (num & 0x0000FF) + amt;
    return "#" + (0x1000000 + (R<255?R<1?0:R:255)*0x10000 + (B<255?B<1?0:B:255)*0x100 + (G<255?G<1?0:G:255)).toString(16).slice(1);
  };

  $('.item:not(:first-child)').click(function(){
      let color = $(this).css("background-color");
      $('#linkToCopy').val(rgb2hex(color));
      $('#linkToCopy').select();
      document.execCommand("copy");
      $(".notify").toggleClass("active");
      $("#notifyType").toggleClass("success");
      setTimeout(function(){
        $(".notify").removeClass("active");
        $("#notifyType").removeClass("success");
      },1000);
  });
  
    updateColors();
});

function rgb2hex(rgb) {
    if (/^#[0-9A-F]{6}$/i.test(rgb)) return rgb;

    rgb = rgb.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/);
    function hex(x) {
        return ("0" + parseInt(x).toString(16)).slice(-2);
    }
    return "#" + hex(rgb[1]) + hex(rgb[2]) + hex(rgb[3]);
}
              
            
!
999px

Console