I'm facing an issue with two CSS classes - container
and top_menu
. The top_menu
should not have a margin on top when used within the container
class, but it somehow does. Removing the container
div resolves this. How can I resolve this problem?
Below is an example:
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: #e1e1e1;
}
.top_menu {
width: 100%;
}
ul.horizontal-menu, .horizontal-menu ul {
list-style-type: none;
margin: 0;
padding: 0;
}
/* Rest of the CSS code */
<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">
<!-- List items for the menu -->
</ul>
</div>
<!-- Container -->
<div class="container">
Container
</div>
<h1 class="txt-center">TEXT</h1>