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. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ 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="container">
  <header class='my-5 text-center'> <h1>Random User Generator</h1></header>
  <main class="main">
    <section class='section-head'>
      <div class="row">
        <div class="col-md-6 d-flex img-responsive flex-column justify-content-center align-items-center">
          <img src="" alt="user image" class='img-thumbnail rounded h-75'>
          
        </div>
        <div class="col-md-6 d-flex  flex-column justify-content-center align-items-center">
          <div class="content w-100 p-2">
            <label for="username">Username:</label>
            <div class="d-flex">
              <input type="text" id='username' class="form-control" readonly>
              <button class='btn-secondary btn' tooltip="click to copy" tooltip-position="top" >Copy</button>
            </div>
            
          </div>
          
          <div class="content w-100 p-2">
            <label for="image" class='align-self-start'>Profile image:</label>
            <div class= "d-flex" role="toolbar">
              <input type="text" id='image' class="form-control" readonly>
              <button class='btn-secondary btn' tooltip="click to copy" tooltip-position="top" >Copy</button>
            </div>
            
          </div>
        </div>
      </div>
    </section>
    <section class="section-body">
      <div class="row d-flex flex-wrap">
        <div class="col-md-6 d-flex  flex-column justify-content-center align-items-center">
          <div class="content w-100 p-2">
            <label for="first">First Name:</label>
            <div class="d-flex">
              <input type="text" id='first' class="form-control" readonly>
              <button class='btn-secondary btn' tooltip="click to copy" tooltip-position="top" >Copy</button>
            </div>
          </div>
        </div>
        <div class="col-md-6 d-flex  flex-column justify-content-center align-items-center">
          <div class="content w-100 p-2">
            <label for="last">Last Name:</label>
            <div class="d-flex">
              <input type="text" id='last' class="form-control" readonly>
              <button class='btn-secondary btn' tooltip="click to copy" tooltip-position="top">Copy</button>
            </div>
          </div>
        </div>
        <div class="col-md-6 d-flex  flex-column justify-content-center align-items-center">
          <div class="content w-100 p-2">
            <label for="email">Email:</label>
            <div class="d-flex">
              <input type="text" id='email' class="form-control" readonly>
              <button class='btn-secondary btn' tooltip="click to copy" tooltip-position="top" >Copy</button>
            </div>
          </div>
        </div>
        <div class="col-md-6 d-flex  flex-column justify-content-center align-items-center">
          <div class="content w-100 p-2">
            <label for="gender">Gender:</label>
            <div class="d-flex">
              <input type="text" id='gender' class="form-control" readonly>
              <button class='btn-secondary btn' tooltip="click to copy" tooltip-position="top" >Copy</button>
            </div>
          </div>
        </div>
        <div class="col-md-6 d-flex  flex-column justify-content-center align-items-center">
          <div class="content w-100 p-2">
            <label for="dob">Date of Birth:</label>
            <div class="d-flex">
              <input type="text" id='dob' class="form-control" readonly>
              <button class='btn-secondary btn' tooltip="click to copy" tooltip-position="top" >Copy</button>
            </div>
          </div>
        </div>
        <div class="col-md-6 d-flex  flex-column justify-content-center align-items-center">
          <div class="content w-100 p-2">
            <label for="age">Age:</label>
            <div class="d-flex">
              <input type="text" id='age' class="form-control" readonly>
              <button class='btn-secondary btn' tooltip="click to copy" tooltip-position="top" >Copy</button>
            </div>
          </div>
        </div>
        <div class="col-md-6 d-flex  flex-column justify-content-center align-items-center">
          <div class="content w-100 p-2">
            <label for="pwd">Password:</label>
            <div class="d-flex">
              <input type="text" id='pwd' class="form-control" readonly>
              <button class='btn-secondary btn' tooltip="click to copy" tooltip-position="top" >Copy</button>
            </div>
          </div>
        </div>
        <div class="col-md-6 d-flex  flex-column justify-content-center align-items-center">
          <div class="content w-100 p-2">
            <label for="uuid">UUID:</label>
            <div class="d-flex">
              <input type="text" id='uuid' class="form-control" readonly>
              <button class='btn-secondary btn' tooltip="click to copy" tooltip-position="top" >Copy</button>
            </div>
          </div>
        </div>
        <div class="col-md-6 d-flex  flex-column justify-content-center align-items-center">
          <div class="content w-100 p-2">
            <label for="street">Street:</label>
            <div class="d-flex">
              <input type="text" id='street' class="form-control" readonly>
              <button class='btn-secondary btn' tooltip="click to copy" tooltip-position="top" >Copy</button>
            </div>
          </div>
        </div>
        <div class="col-md-6 d-flex  flex-column justify-content-center align-items-center">
          <div class="content w-100 p-2">
            <label for="city">City:</label>
            <div class="d-flex">
              <input type="text" id='city' class="form-control" readonly>
              <button class='btn-secondary btn' tooltip="click to copy" tooltip-position="top" >Copy</button>
            </div>
          </div>
        </div>
        <div class="col-md-6 d-flex  flex-column justify-content-center align-items-center">
          <div class="content w-100 p-2">
            <label for="state">State:</label>
            <div class="d-flex">
              <input type="text" id='state' class="form-control" readonly>
              <button class='btn-secondary btn' tooltip="click to copy" tooltip-position="top">Copy</button>
            </div>
          </div>
        </div>
        <div class="col-md-6 d-flex  flex-column justify-content-center align-items-center">
          <div class="content w-100 p-2">
            <label for="post">Post Code:</label>
            <div class="d-flex">
              <input type="text" id='post' class="form-control" readonly>
              <button class='btn-secondary btn' tooltip="click to copy" tooltip-position="top">Copy</button>
            </div>
          </div>
        </div>
        <div class="col-md-6 d-flex  flex-column justify-content-center align-items-center">
          <div class="content w-100 p-2">
            <label for="phone">Phone:</label>
            <div class="d-flex">
              <input type="text" id='phone' class="form-control" readonly>
              <button class='btn-secondary btn' tooltip="click to copy" tooltip-position="top" >Copy</button>
            </div>
          </div>
        </div>
      </div>
    </section>
    <section class='new py-4 d-flex justify-content-center '>
      <button class='btn btn-warning px-5 btn-md-lg' id='new'> Generate New User</button>
    </section>
  </main>
</div>
<footer class='bg-dark text-white text-center p-3'>
    <p class='mb-0'>Made with Love by <a href="https://www.linkedin.com/in/gskumawat/" class='px-1 text-warning' target='_blank'>Gouri Shankar</a></p>
</footer>
              
            
!

CSS

              
                body{
  background: linear-gradient( 90deg, #f857a6, #ff5858);
}
section{
  border-bottom: solid 1px #6c757d;
}
.btn:focus{
  outline: none;
}
.btn{
  margin:auto;
}
button:hover{
    box-shadow: 0 3px 8px 0 rgba(0,0,0,.2), 0 0 0 1px rgba(0,0,0,.08);
}
[tooltip]{
/*   margin:20px 60px; */
  position:relative;
  display:inline-block;
}
[tooltip]::before {
    content: "";
    position: absolute;
    top:-6px;
    left:50%;
    transform: translateX(-50%);
    border-width: 4px 6px 0 6px;
    border-style: solid;
    border-color: rgba(0,0,0) transparent transparent     transparent;
    z-index: 99;
    opacity:0;
}

[tooltip-position='top']::before{
  left:50%;
}

[tooltip]::after {
    content: attr(tooltip);
    position: absolute;
    left:50%;
    top:-6px;
    transform: translateX(-50%)   translateY(-100%);
    background: rgba(0,0,0);
    text-align: center;
    color: #fff;
    padding:4px 2px;
    font-size: 12px;
    min-width: 80px;
    border-radius: 5px;
    pointer-events: none;
    padding: 4px 4px;
    z-index:99;
    opacity:0;
}

[tooltip-position='top']::after{
  left:50%;
}

[tooltip]:hover::after,[tooltip]:hover::before {
   opacity:1;
  transition-delay: 0.3s;
}

/* .input{
  margin-left:135px
} */
              
            
!

JS

              
                window.onload = (event)=>{
  ajaxFunc();
}

const ajaxFunc = ()=>{
  $.ajax({
    url: 'https://randomuser.me/api/',
    method: 'get'
  })
  .then((data)=>{
    let user = data.results[0];
    // console.log(user);
    showUserInfo(user);
  })
  .catch(err=>{
    console.log('Error happened : '+ err.message);
  });
} 
const showUserInfo = (user)=>{
  $('#username').val(user.login.username);
  $('#image').val(user.picture.large);
  $('img').attr('src', user.picture.large);
  $('#first').val(user.name.first);
  $('#last').val(user.name.last);
  $('#email').val(user.email);
  $('#gender').val(user.gender);
  $('#dob').val(user.dob.date.split('T')[0].split('-').reverse().join('-'));
  $('#age').val(user.dob.age);
  $('#pwd').val(user.login.password);
  $('#uuid').val(user.login.uuid);
  $('#street').val(user.location.street.number + ", " + user.location.street.name);
  $('#city').val(user.location.city);
  $('#state').val(user.location.state);
  $('#post').val(user.location.postcode);
  $('#phone').val(user.cell);
}

//generate new user
$('#new').on('click', (event)=>{
  event.preventDefault();
  ajaxFunc();
});

$('.btn-secondary').on('click', function(event){
  event.currentTarget.parentNode.childNodes[1].select();
  // console.log(event.currentTarget.prev())
  document.execCommand('copy');
  // console.log($(this).attr('tooltip'));
  $(this).attr('tooltip', 'copied');
});

$('.btn-secondary').on('mouseleave',function(event){
  $(this).attr('tooltip', 'click to copy');
})
              
            
!
999px

Console