LOADING...

Preview

Pen ID
Unlock Campus Themeforest adv

 

Code

Get in touch

Instead of just having a mailto link, why not provide options? Let the user decide how they send an email!

CSS
* {
  box-sizing: border-box;
}
html,
body {
  height: 100%;
}
body {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  height: 100%;
  padding: 10px;
  font-family: 'Source Sans Pro', serif;
  color: #333;
  background: #f2f2f2;
}
h1 {
  font-family: 'Bree Serif', sans-serif;
  font-size: 45px;
  font-weight: 400;
  margin-bottom: 20px;
}
p {
  font-size: 22px;
  line-height: 1.6em;
}
.button {
  background: #9ccc65;
  border: 0;
  outline: 0;
  font-family: 'Source Sans Pro', serif;
  font-weight: bold;
  text-transform: uppercase;
  text-decoration: none;
  letter-spacing: 1px;
  color: #fff;
  cursor: pointer;
}
.button:hover {
  background: #a5d174;
}
.button:active {
  background: #8cb75a;
}
.button--small {
  display: flex;
  justify-content: center;
  align-items: center;
  min-width: 70px;
  padding: 5px 10px;
  border-radius: 0 5px 5px 0;
  font-size: 14px;
}
.button--large {
  position: relative;
  padding: 15px 30px;
  border-radius: 5px;
  font-size: 16px;
}
.button--large:active {
  top: 1px;
}
.content {
  text-align: center;
  max-width: 350px;
}
.email {
  position: relative;
}
.overlay {
  position: fixed;
  z-index: -1;
  background: rgba(0,0,0,0.5);
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  will-change: opacity;
}
.email--is-active .overlay {
  opacity: 1;
  z-index: 1;
  transition: opacity 0.2s;
}
.dialog {
  position: absolute;
  z-index: 2;
  top: 0;
  display: flex;
  flex-direction: column;
  width: 100%;
  box-shadow: 0 48px 80px -32px rgba(0,0,0,0.3);
  text-align: left;
  transform: translateY(-100%) scale(0);
  transform-origin: bottom;
  opacity: 0;
}
.email--is-active .dialog {
  transform: translateY(-100%) scale(1);
  opacity: 1;
  transition: transform 0.2s, opacity 0.2s;
}
.dialog:after {
  content: '';
  position: absolute;
  left: 50%;
  bottom: 0;
  width: 20px;
  height: 20px;
  background: #fff;
  border-radius: 0 0 5px 0;
  transform: translate(-50%, 50%) rotate(45deg);
  transform-origin: center;
}
.dialog__top {
  padding: 30px;
  background: #f2f2f2;
  border-radius: 5px 5px 0 0;
}
.dialog__bottom {
  padding: 30px;
  background: #fff;
  border-radius: 0 0 5px 5px;
}
.control {
  display: flex;
}
.input {
  font-family: 'Source Sans Pro', sans-serif;
  width: 100%;
  height: 43px;
  padding: 8px 10px;
  border-radius: 5px 0 0 5px;
  border: 1px solid #ccc;
  border-right: 0;
  background: #fff;
  font-size: 18px;
}
.label {
  display: block;
  font-size: 14px;
  font-weight: bold;
  text-transform: uppercase;
  margin-bottom: 10px;
  margin-left: 3px;
}
JS
const button = document.querySelector('.js-button')
    , overlay = document.querySelector('.js-overlay')
    , email = document.querySelector('.js-email')
    , copy = document.querySelector('.js-copy')
    , clientSelect = document.querySelector('.js-client-select')
    , clientOpen = document.querySelector('.js-client-open')

button.addEventListener('click', function() {
  email.classList.add('email--is-active')
})

overlay.addEventListener('click', function() {
  email.classList.remove('email--is-active')
})

clientSelect.addEventListener('change', function() {
  let clientSelection = clientSelect.value
    
  if (clientSelection === 'mailto:example@gmail.com') {
    clientOpen.setAttribute('href', clientSelection)
    clientOpen.removeAttribute('target')
  } else {
    clientOpen.setAttribute('href', clientSelection)
    clientOpen.setAttribute('target', '_blank')
  }
})

new Clipboard('.js-copy')
Host Instantly Drag and Drop Website Builder

 

Term
Mon, 11/27/2017 - 21:36

Related Codes

Pen ID
Pen ID
Pen ID