3
Well, I have two classes:
1 - container
who receives some information
2 - top_menu
who receives the menu.
I can’t explain how this happens, but every time I put a div with the class container
the menu creates a margin at the top.
someone knows why this happens?
If you remove the div container
the menu is without margin, the right way. But I need the div container
.
body {
margin: 0;
color:#484848;
font-family: 'Verdana', sans-serif;
}
.container {
left: 0;
right: 0;
margin: 10px auto 10px auto;
width: 95%;
border-radius: 4px;
background: #FFFFFF;
}
.top_menu {
width: 100%;
}
ul.horizontal-menu, .horizontal-menu ul {
list-style-type: none;
margin: 0;
padding: 0;
}
.horizontal-menu {
float: left;
width:100%;
background: #616161;
}
.horizontal-menu li {
float: left;
display: block;
padding: 25px;
color: #FFFFFF;
text-decoration: none;
text-transform: uppercase;
-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;
}
.top_menu_extra {
background-color: #616161;
width: 100%;
display: none;
border: 0 solid #484848;
border-top-width: 1px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<!-- Top Menu -->
<div class="top_menu">
<ul class="horizontal-menu">
<li id="sub"> <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>
</ul>
</div>
<!-- Container -->
<div class="container">
Container
</div>
<h1 class="txt-center">TEXTO</h1>
In its CSS, the
.container
has edge at the top.– Leon Freire
no. I put the div css
container
in the question.– Hugo Borges
So:
margin: 10px auto 10px auto;
. The first 10px is at the top.– Leon Freire
the menu is outside the
.container
this and the problem. the menu has to be at the top without margin, and then have to come the.container
on the margin.– Hugo Borges