JSFiddle - React, Tailwind, and code Playground
by Manju06
HTML
<div id="login-box">
<span class="login-head">
<h5 align="center" class="head">Login</h5><hr />
</span>
<ul class="drop-down">
<li>
<!-- LOGIN and SIGNUP tabs -->
<div id="login-title" class="drop-down-head" onClick="loginExpand()">LOGIN</div>
<div id="signup-title" class="drop-down-head" onClick="signupExpand()">SIGNUP</div>
<!-- login content to be expanded from 0 height to auto when "login div" above is clicked -->
<div id="login-content" style=" display:none;">
<div class="input column" id="first-name">
<input placeholder="First Name" type="text" class="validate white">
<div id="first-name-tooltip" class="tooltip">First Name</div>
</div>
CSS
#login-content, #signup-content {
height: 0;
transition: height .5s;
-moz-transition: height .5s;
-webkit-transition: height .5s;
-o-transition: height .5s;
}
/* class to be added to div */
.expand {
height: auto;
overflow: visible;
}
/* link-like features to div */
.drop-down-head:hover {
background: #8fffad;
cursor: pointer;
}
JavaScript
document.addEventListener('DOMContentLoaded',function() {
document.getElementById('login-title').addEventListener('click',loginExpand);
});
function loginExpand() {
document.getElementById('login-content').style.display = 'block';
$( "#login-content" ).first().fadeIn( "slow" );
}