.global-menu2 {
position:relative;
width:100%;
}
.global-menu2 li span img {
width:50px;
height:50px;
}
ul.global-menu2 li a {
display: block;
text-decoration: none;
padding-top:5px;
padding-bottom:5px;
background-color:#b6cce8;
text-align:center;
width:100%;
min-width:200px;
}
ul.global-menu ul li a {
width: 100%;
}
ul.global-menu2 li {
float: left;
}
ul.global-menu2 li ul {
display:none;
}
ul.global-menu2 ul li {
clear: both;
margin-left: 20px;
padding-top:5px;
padding-bottom:5px;
}
ul.global-menu2 ul li :hover {
background-color:pink;
}
.shown {
display: block !important;
}
JavaScript
$(function () {
$('.global-dropdown span').bind('click.mynamespace', function (obj) {
dropdown(obj.currentTarget);
});
});
var breakPoint = 10000;
$(window).resize(function () {
if ($(window).width < breakPoint) {
handleBreak();
} else {
undoBreak();
}
});
function handleBreak() {
console.log("Width: " + $(window).width() + " breaking!");
var toMove = $(".global-menu").remove();
$(toMove).removeClass("global-menu");
$(toMove).addClass("global-menu2");
$(toMove).insertBefore('#steelContent');
$('.global-menu2 li span').attr("onclick", "dropdown(this)");
}
function undoBreak() {
console.log("Width: " + $(window).width() + " undoing breaking!");
var toMove = $(".global-menu2").remove();
$(toMove).removeClass("global-menu2");
$(toMove).addClass("global-menu");
$(toMove).insertAfter('#steelContent');
$('.global-menu li span').attr("onclick", "return false;");
}
function dropdown(obj) {
console.log(obj);
//Get the UL we want to show
var ul = $(obj).parent().find("ul");
//If its hidden then show it
if (!$(ul).hasClass("shown")) {
console.log("SHOWING");
$(ul).addClass("shown");
}
//If its shown then hide it
else {
console.log("HIDING");
$(ul).removeClass("shown");
}
}
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.