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

              
                <div class="wrapper">
  <div class="title-wrapper">
    <h1 class="title">Password Generator</h1>
  </div>
  <div class="inner-wrapper">
    <div class="password-wrapper">
    <div class="password-here" id="password-here">
    ----
  </div>
    <button id="copy" class="copy">Copy</button>
    <div class="alert" id="alert"><span class="message" id="message"></div>
  </div>
  <p class="instructions">Select your options and click the "generate" button. Your passord will appear above.</p>
  <div class="controls">
    <div class="control length" id="length-box" >
      <label for="length">Password Length</label>
      <input type="range" id='length' min="4" max="20"list="tickmarks">
      <datalist id="tickmarks">
        <option value="4" label="4">
        <option value="5">
        <option value="6">
        <option value="7">
        <option value="8">        
        <option value="9">
        <option value="10">
        <option value="11">
        <option value="12" label="12">
        <option value="13">
        <option value="14">
        <option value="15">
        <option value="16">
        <option value="17">
        <option value="18">
        <option value="19">
        <option value="20">
      </datalist>
    </div>
    <div class="control">
      <input type="checkbox" id="lowercase">
      <label class="check-label" for="lowercase"><span class="checkbox">Use lowercase letters</span></label>
    </div>
    <div class="control">
      <input type="checkbox" id="uppercase">
      <label class="check-label" for="uppercase"><span class="checkbox">Use uppercase letters</span></label>
    </div>
    <div class="control">
      <input type="checkbox" id="numbers">
      <label class="check-label" for="numbers"><span class="checkbox">Use numbers</span></label>
    </div>
    <div class="control">
      <input type="checkbox" id="punctuation">
      <label class="check-label" for="punctuation"><span class="checkbox">Use special characters</span></label>
    </div>
    
        

    <button class="generate" id="generate">Generate!</button>
  </div>
  </div>
</div>

              
            
!

CSS

              
                $mauve: #af5095
$seafoam: #58d8bf
body
  min-height: 100vh
  padding-top: 100px
  background: linear-gradient(20deg, #b2085a 0%, #52149e 51%, #089bd1 95%)
  font-family: 'Kanit', sans-serif
  font-weight: 300
.instructions
  font-size: .9rem
  text-align: left
h1,h2,h3,h4,h5,h6
  font-weight: 500
  margin: 0
.title-wrapper
  background: $mauve
  padding: 2px 10px
  color: white
h1
  font-size: 1.1rem
.inner-wrapper
  padding: 20px
.wrapper
  overflow: hidden
  margin: auto
  width: 90%
  max-width: 380px
  background: white
  border-radius: 5px
  box-shadow: 3px 3px 2px rgba(black, .4)
  display: flex
  flex-flow: column wrap
  .password-wrapper
    position: relative
    border: 2px solid lightgray
    color: gray
    padding: 2px 2px 2px 8px
    border-radius: 5px
    text-align: left
    display: flex
    justify-content: space-between
    .alert
      position: absolute
      
      padding: 0 5px
      border-radius: 2px
      width: 21ch
      height: 89%
      left: 2px
      top: -100%
      width: 96%
      text-align: center
      color: #333
      
      opacity: 0
      transition: all .5s ease
      &.success
        background: rgba($seafoam, .9)
        opacity: 1
      &.fail
        background: rgba(#bc5a76, .9)
        color: white
        opacity: 1
    .copy
      height: 100%
      width: 50px
      background: $mauve
      border: 0
      color: white
      border-radius: 2px
      padding: 8px
      cursor: pointer
      transition: all .3s ease
      &:hover
        background: lighten($mauve, 5%)
  .controls
    text-align: left
    display: flex
    flex-flow: column wrap
    .control
      padding: 3px
      border-bottom: 1px solid lightgray
      width: 100%
      margin: 2px
    .generate
      width: 100%
      border: 0
      color: white
      background: $mauve
      border-radius: 3px
      height: 25px
      margin-top: 10px
      transition: all .3s ease
      &:hover
        background: lighten($mauve, 5%)
      
#length-box
  width: 100%
  input
    width: 100%
  
input[type="checkbox"] 
  visibility: hidden
label.check-label
  position: relative
  &:before
    content: ""
    height: 1rem
    width: 1rem
    left: -24px
    top: 0
    border: .5px solid lightgray
    position: absolute
    background: transparent
    transition: all .3s cubic-bezier(0,.82,1,1.81)
input[type="checkbox"]:checked + label.check-label:before
  content: '\f00c'
  font-family: 'FontAwesome'
  font-size: .8rem
  color: $seafoam
  text-align: center
  background: lighten($seafoam, 30%)
  transition: all .3s cubic-bezier(0,.82,1,1.81)


              
            
!

JS

              
                var clipboard = new Clipboard('.copy')
var lowercase = "abcdefghijklmnopqrstuvwxyz",
  uppercase = "ABCDEFGHIJKLMNOPQRSTUVWXYZ",
  numbers = "0123456789",
  punctuation = "!@#$%^&*()_+~`|}{[]:;?><,./-=",
  lowercaseInput = document.getElementById("lowercase"),
  uppercaseInput = document.getElementById("uppercase"),
  punctuationInput = document.getElementById("punctuation"),
  numbersInput = document.getElementById("numbers"),
  lengthInput = document.getElementById("length"),
  passwordFeild = document.getElementById("password-here"),
  generateButton = document.getElementById("generate"),
  copyButton = document.getElementById("copy"),
  plength,
  userPassword,
  passwordCharSet;

function generate() {
  userPassword = "";
  passwordCharSet = "";
  if (lowercaseInput.checked) {
    passwordCharSet += lowercase;
  }
  if (uppercaseInput.checked) {
    passwordCharSet += uppercase;
  }
  if (punctuationInput.checked) {
    passwordCharSet += punctuation;
  }
  if (numbersInput.checked) {
    passwordCharSet += numbers;
  }
  plength = Number(lengthInput.value);

  for (let i = 0; i < plength; i++) {
    userPassword += passwordCharSet.charAt(
      Math.floor(Math.random() * passwordCharSet.length)
    );
  }
  if (userPassword == "") {
    let alertbox = document.getElementById('alert');
    alertbox.innerHTML = "Please select an option before generating"
    alertbox.classList.add('fail');
    setTimeout(function(){ 
      alertbox.classList.remove('fail');
    }, 3000);
  } else {
    passwordFeild.innerHTML = userPassword;
  }
  copyButton.setAttribute("data-clipboard-text", userPassword)
}
generateButton.addEventListener("click", generate);

clipboard.on('success', function(e) {
    console.info('Action:', e.action);
    console.info('Text:', e.text);
    console.info('Trigger:', e.trigger);
    let alertbox = document.getElementById('alert');
    alertbox.innerHTML = "Copied!"
    alertbox.classList.add('success');
    setTimeout(function(){ 
      alertbox.classList.remove('success');
    }, 3000);
    
    e.clearSelection();
});

clipboard.on('error', function(e) {
    console.error('Action:', e.action);
    console.error('Trigger:', e.trigger);
  let alertbox = document.getElementById('alert');
    alertbox.innerHTML = "Try select the text to copy"
    alertbox.classList.add('fail');
    setTimeout(function(){ 
      alertbox.classList.remove('fail');
    }, 3000);
});
              
            
!
999px

Console