JSFiddle - React, Tailwind, and code Playground

HTML

<div id="usericon" tabindex="0" onclick="showMenu('userbody')">
	<div id="userbody" tabindex="0" onblur="setTimeout(function(){hideMenu('userbody');}, 100);">
        <div style="margin: 20px 15px; width: 230px; height: 320px;">
            <div class="loginregisterswitch">
                <div>Войти</div>
                <div>Зарегистрироваться</div>
            </div>
            <form method="POST" name="loginform" action="$HOME_PAGE_LINK$/index/">
                <div class="iconedinput" id="loginput">
                    <div></div>
                    <input class="loginField" type="text" name="user" value="" size="20" style="width:100%;" maxlength="50" placeholder="Логин" tabindex="1" onfocus="pauseHiding('userbody');" onchange="resumeHiding('userbody', 100);"/>
                </div>
                <div class="iconedinput" id="passinput">
                    <div></div>
                    <input class="loginField" type="password" name="password" size="20" style="width:100%" maxlength="15" placeholder="Пароль" tabindex="0" onfocus="pauseHiding('userbody');" onblur="resumeHiding('userbody', 100);"/>
                </div>
                <label for="rem">
                    <input id="rem" type="checkbox" name="rem" value="1" checked tabindex="0" onfocus="pauseHiding('userbody');" onblur="resumeHiding('userbody', 100);"/>Запомнить
                </label> 
                <input type="submit" value="Войти" tabindex="0" onfocus="pauseHiding('userbody');" onblur="resumeHiding('userbody', 100);"/> 
                <input type="hidden" name="a" value="2"/>
                <input type="hidden" name="redirect" value="0"/> 
            </form> 
        </div>
     </div>
</div>

CSS

#usericon {
	display: block;
	background: black no-repeat center left;
	padding: 1px 1px;
	border: solid 1px #ccc;
	 
	-webkit-border-radius: 10em;
	-moz-border-radius: 10em;
	-ms-border-radius: 10em;
	-o-border-radius: 10em;
	border-radius: 10em;
	 
	width: 19px;
	height: 19px;
	padding-left: 0px;
	color: transparent;
	cursor: pointer;
}
#usericon:hover{
 background-color: orange;
}
#usericon:focus{
 background-color: white;
}
#userbody {
	z-index: 100;
	cursor: auto;
        position: relative;
        width: 270px;
        height: 350px;
        top: 15px;
	padding: 1px;
	padding-bottom: 5px;
	background-color: #fff;
	border: solid 1px #ccc;
	-webkit-border-radius: 0.25em;
	-moz-border-radius: 0.25em;
	-ms-border-radius: 0.25em;
	-o-border-radius: 0.25em;
	border-radius: 0.25em;
	display: none;
}

JavaScript

function iterateChildren(fromElement, whatToDoFunc){
	var child = fromElement.firstElementChild;
	while (child != null) {
		iterateChildren(child, whatToDoFunc);
		child = child.nextElementSibling;
	}
	whatToDoFunc(fromElement);
}

function showMenu(containerId) {
	var el = document.getElementById(containerId);
	var setVisible = function(element){
        if (element.tagName == 'A') element.style.display = 'inline';
        else
            if (element.tagName != 'SCRIPT' && element.tagName != 'STYLE') element.style.display = 'block';
        };
	iterateChildren(el, setVisible);
        el.focus();
}

function hideMenu(containerId) {
	var el = document.activeElement;
	var isDerivedFromCart = 0;
	var elP = el.parentNode;
	while (elP != null)
	{
		if (elP.getAttribute('id')==containerId)
		{
			isDerivedFromCart = 1;
			break;
		}
                if (elP.tagName == 'HTML') break;
		elP = elP.parentNode;
	}
	if (isDerivedFromCart == 0)
		document.getElementById(containerId).style.display='none';
}

function pauseHiding(hiderId) {
	var hider = document.getElementById(hiderId);
	hider.onblur = null;
}

function resumeHiding(hiderId, timeout) {
	var hider = document.getElementById(hiderId);
	hider.onblur = "setTimeout(function(){hideMenu(hiderId);}, timeout);";
	hider.focus();
}