JSFiddle - React, Tailwind, and code Playground
by joplomacedo
HTML
<link href="https://fonts.googleapis.com/css?family=Lato:300,400,700,900" rel="stylesheet">
<div class="bar">
<div class="bar_row">
<div class="dropdown__toggle">
<p class="h">Not ready to book? Tap here.</p>
</div>
<div class="dropdown__dropdown is-inactive">
<p class="l">If you're not ready to book, leave us your email and we'll keep you in the loop with special updates and offers. Don't worry ;) We'll only email you when it's worth it.</p>
<form action="">
<input type="text" placeholder="Your email address">
<button class="b">GET OFFERS</button>
</form>
<p class="pp">By clicking the button 'Get Offers', you agree to our <a>privacy policy.</a></p>
</div>
</div>
</div>
CSS
* {
-webkit-box-sizing: border-box;
box-sizing: border-box;
margin: 0;
padding: 0;
border: 0;
font: inherit;
}
body,
button {
-webkit-font-smoothing: antialiased;
}
.bar {
color: #1f1f1f;
overflow: hidden;
font-family: Lato;
font-size: 11px;
word-spacing: .7px;
padding: .94em 1.6em;
position: fixed;
bottom: 0;
left: 0;
right: 0;
letter-spacing: .px;
box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.13), 0 1px 5px 0 rgba(0, 0, 0, 0.08);
border-radius: 2px 2px 0 0;
}
.bar_row {
max-width: 1000px;
margin: auto;
}
.pad_block {
}
.bar:not(.is-open):hover {
background-color: hsla(11, 85%, 66%, 1);
}
.bar:not(.is-open) {
background-color: #e75635;
}
.bar:not(.is-open) .h {
color: #fff;
}
.bar.is-open {
background-color: #fff;
}
.dropdown__dropdown {
padding-top: .4em;
animation: openDropdown .3s .3s backwards;
}
@keyframes openDropdown {
0% {
transform: translateY(10%);
opacity: 0;
}
}
.bar:not(.is-open) .dropdown__dropdown {
display: none;
}
.l,
.r {
}
.l {
padding-right: .9em;
}
.h,
.l {
}
.h {
color: #0b140f;
font-weight: 600;
font-size: 1.25em;
}
.l {
padding-right: .9em;
color: #060606;
font-weight: 300;
line-height: 1.3;
margin-top: 0.2em;
font-size: 1.1em;
margin-bottom: .6em;
}
.pp {
font-size: .9em;
margin-bottom: .7em;
color: #666;
}
a {
font-weight: 900;
border-bottom: 1px solid;
}
form {
Xoverflow: hidden;
}
input,
.b {
display: block;
width: 100%;
padding: .8em;
border-radius: 2px;
}
input {
margin-bottom: .6em;
background-color: #eee;
}
input {
background-color: #eee;
margin-bottom: .6em;
}
.b {
background-color: #e75635;
color: #fff;
letter-spacing: .7px;
word-spacing: 1px;
font-weight: 700;
margin-bottom: .8em;
box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.13), 0 1px 5px 0 rgba(0, 0, 0, 0.08);
}
JavaScript
var toggle = document.querySelector('.dropdown__toggle'),
dropdown = document.querySelector('.dropdown__dropdown'),
bar = document.querySelector('.bar'),
form = document.querySelector('form');
toggle.addEventListener('click', function ( e ) {
bar.classList.toggle('is-open');
});
form.addEventListener('submit', function ( e ) {
e.preventDefault();
return false;
});