0
The icone is not aligned with the text
Good follows the code of the menu, I already thank the help.
$(".top_menu ul").each(function() {
alignMenu(this);
var robj = this;
$(window).resize(function() {
$(robj).append($($($(robj).children("li.hideshow")).children("ul")).html());
$(robj).children("li.hideshow").remove();
alignMenu(robj);
});
function alignMenu(obj) {
var w = 0;
var mw = $(obj).width() - 150;
var i = -1;
var menuhtml = '';
jQuery.each($(obj).children(), function() {
i++;
w += $(this).outerWidth(true);
if (mw < w) {
menuhtml += $('<div>').append($(this).clone()).html();
$(this).remove();
}
});
$(obj).append('<li class="hideshow">MAIS <i class="material-icons">keyboard_arrow_down</i><ul>' + menuhtml + '</ul></li>');
$(obj).children("li.hideshow ul").css("top", $(obj).children("li.hideshow").outerHeight(true) + "px");
// Abre o menu
$(obj).children("li.hideshow").click(function() {
$(this).find("ul").animate({
height: 'toggle'
}, 'fast');
});
}
});
$(".top_menu ul li").click(function() {
// Verifica se tem link
if (typeof $(this).data('link') !== 'undefined') {
//document.location.href = $(this).data('link');
console.log('link ok');
}
});
.material-icons {
width: 24px;
overflow: hidden;
vertical-align: middle;
font-size: 24px;
}
.top_menu {
width: 100%;
background: #616161;
}
ul.horizontal-menu,
.horizontal-menu ul {
list-style-type: none;
margin: 0;
padding: 0;
}
.horizontal-menu {
float: left;
width: 100%;
}
.horizontal-menu li {
float: left;
display: block;
padding: 25px;
color: #FFFFFF;
text-decoration: none;
-webkit-transition: border-color .218s;
-moz-transition: border .218s;
-o-transition: border-color .218s;
transition: border-color .218s;
background: #616161;
cursor: pointer;
}
.horizontal-menu li .material-icons {
margin: -10px;
}
.hideshow ul li {
width: 250px;
text-align: center;
}
.horizontal-menu li:hover {
border-bottom: 3px solid rgb(246, 83, 20);
padding-bottom: 22px;
background: #484848;
}
.horizontal-menu li.hideshow ul {
position: absolute;
display: none;
left: -203px;
width: 300px;
}
.horizontal-menu li.hideshow {
position: relative;
}
.hideshow ul {
padding-bottom: 7px;
background: #616161;
border-radius: 0px 0px 4px 4px;
margin-top: 25px;
}
<!-- Material Icons (Google) -->
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<!-- Inicializa o Jquery -->
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<div class="top_menu">
<ul class="horizontal-menu">
<li> <i class="material-icons">search</i> </li>
<li data-link="http://www.google.com">MENU 1</li>
<li data-link="http://www.google.com">MENU 2</li>
<li data-link="http://www.google.com">MENU 3</li>
<li data-link="http://www.google.com">MENU 4</li>
<li data-link="http://www.google.com">MENU 5</li>
<li data-link="http://www.google.com">MENU 6</li>
<li data-link="http://www.google.com">MENU 7</li>
<li data-link="http://www.google.com">MENU 8</li>
<li data-link="http://www.google.com">MENU 9</li>
<li data-link="http://www.google.com">MENU 10</li>
<li data-link="http://www.google.com">MENU 11</li>
<li data-link="http://www.google.com">MENU 12</li>
<li data-link="http://www.google.com">MENU 13</li>
<li data-link="http://www.google.com">MENU 14</li>
</ul>
</div>
OK worked out, now it is missing only the bottom, the
top_menu
. Knows how to solve?– Hugo Borges
What do you mean? Explain more because I don’t understand.
– user76271
I have a div with the class
top_menu
she has to be a div withwidth:100%
to create a bar across the page understood. It has to be the height of the menu. Understood?– Hugo Borges
look at the issue I did in the post see if it helps.
– user76271
It didn’t work. Well look at the example image that I set http://i.imgur.com/hmud8Q8.png
– Hugo Borges
@Guilerme Alves, I edited the question to better explain the problems. If you can help me I thank.
– Hugo Borges
Did it work? or not?
– user76271
it worked yes, thank you
– Hugo Borges