JSFiddle - React, Tailwind, and code Playground
by dshilkret
HTML
<!DOCTYPE HTML>
<html>
<body>
<div id="wrapper">
<div id="container">
<div id="modes">
<div class="elements" id="list">
<a href="">menu_item_1</a>
</div>
<div class="elements" id="search">
<a class="link" href="">menu_item_2</a>
</div>
<div class="elements" id="program">
<a href="">menu_item_3</a>
</div>
</div>
<div id="infobox">
<p id="list_info" class="infobox">
info_1
</p>
<p id="search_info"class="infobox">
info_2
</p>
<p id="program_info"class="infobox">
info_3
</p>
<form method="post" action=""></form>
<input type="text" name="search_field" placeholder="type here" />
</form>
</div>
<div id="arrow"></div>
<div id="activated"></div>
</div>
</div>
</body>
</html>
CSS
#wrapper {
position: relative;
margin: 0 auto;
width: 300px;
height: 500px;
/*background-color: black;*/
}
/*mode_selections*/
#modes {
width: 140px;
height: 64px;
background-color: white;
position: absolute;
top: 200px;
left: 15px;
}
.icons {
float: left;
padding-right: 10px;
}
.elements {
padding: 0px 0px 8px 0px;
}
.elements a {
font-family: 'Quicksand';
font-size: 14px;
padding-top: 1px;
text-decoration: none;
color: black;
}
a:hover {
color: #FFA500;
}
#infobox {
width: 140px;
height: 100px;
background-color: #FFD700;
position: absolute;
top: 190px;
left: 115px;
}
#infobox p {
padding: 10px;
font-size: 10px;
font-family: 'Quicksand';
}
#arrow {
position: absolute;
width: 15px;
height: 17px;
background-color: black;
display: none;
left: 100px;
}
#list_info {
display: none;
}
#search_info {
display: none;
}
#program_info {
display: none;
}
input[type=text] {
moz-appearance:none;
-webkit-appearance:none;
position: absolute;
top: 79px;
left: -1px;
background-color: black;
color: white;
outline: none;
border: none;
width: 126px;
height: 20px;
padding-left: 15px;
display: none;
}
span {
font-weight: bold;
}
#activated {
width: 10px;
height: 10px;
background-color: green;
display: none;
position: absolute;
top: 237px;
border-radius: 100px;
}
input::-webkit-input-placeholder {
font-style: italic;
}
input:-moz-placeholder {
font-style: italic;
}
#dollar_sign {
position: absolute;
top: 83px;
left: 4px;
color: white;
font-size: 14px;
display: none;
}
JavaScript
$(function() {
$(".elements").mouseover(
//mouse over
function() {
activateMenuItem($(this)); //see bottom of page for this function
}
//on click we want to disable the hover function, as well as assign the same events as above (move arrow, display text)
).click(function(e) {
var bulletTop = $(this).position().top + 207; //edit this number for bullet position
$("#activated").show().css("top", bulletTop);
$(".elements").off("hover"); //turn off the hover function for all menu items
if($(this).attr("id") == "search") {
var focusDelay = $("input[type=text]").fadeIn(100);
setTimeout(function(){
$(focusDelay).focus();
},1000);
}else {
$("input[type=text]").hide();
}
activateMenuItem($(this)); //do same as on hover
e.preventDefault();
});
function activateMenuItem(item) {
var arrowTop = item.position().top + 205; //edit this number for arrow position
var boxName = "#" + item.attr("id") + "_info";
$("#arrow").show().css("top", arrowTop);
$(".infobox").hide();
$(boxName).show();
}
});