To ensure the main ul
displays properly, you can set a fixed width like so:
#navigation ul {
list-style-type: none;
padding: 0px;
width:80px; /*Simply include this property to define the width*/
}
View the example below :
function toggleDisplay(targetId) {
if (document.getElementById) {
target = document.getElementById(targetId);
if (target.style.display == "none") {
target.style.display = "";
} else {
target.style.display = "none";
}
}
}
.icon {
position: relative;
width: 1em;
height: 1em;
background-color: orange;
}
.icon-minus {
position: relative;
top: 0;
left: 0;
}
.icon-minus:after {
background-color: #fff;
width: 8px;
height: 2px;
position: absolute;
top: 7px;
left: 3.5px;
z-index: 4;
content: "";
}
.icon-plus {
position: relative;
top: 0;
left: 0;
}
.icon-plus:after {
background-color: #fff;
width: 8px;
height: 2px;
position: absolute;
top: 7px;
left: 4px;
content: "";
}
.icon-plus:before {
background-color: #fff;
width: 2px;
height: 8px;
border-radius: 1px;
-webkit-border-radius: 1px;
-moz-border-radius: 1px;
position: absolute;
top: 4px;
left: 7px;
content: "";
}
#navigation ul {
list-style-type: none;
padding: 0px;
width:80px; /*Add this property for proper display*/
}
#navigation ul li {
border-top: 2px solid orange;
border-right: 1px solid orange;
border-bottom: 1px solid orange;
margin-bottom: 5px;
/* padding: 0;
margin: 0;
width: 140px; */
}
#navigation li {
border-right: 1px solid orange;
border-top: 2px solid orange border;
}
#navigation li li {
border-top: 1px solid grey;
}
#navigation a {
text-decoration: none;
}
<div id="navigation" style="float:left">
<ul>
<li>
<a href="#" onclick="toggleDisplay('sectionOneLinks');return false;" class="filtersNav">Click me</a>
<ul id="sectionOneLinks" style="display: none;">
<li><a href="#">A link to a page aaaaaaaaaa</a></li>
<li><a href="#">A link to a page</a></li>
<li><a href="#">A link to a page</a></li>
<li><a href="#">A link to a page</a></li>
</ul>
</li>
<li>
<a href="#" onclick="toggleDisplay('sectionTwoLinks');return false;">Click me</a>
<span style="display:inline-block; float:right" class="icon icon-plus"></span>
<ul id="sectionTwoLinks" style="display: none;">
<li><a href="#">A link to a page</a></li>
<li><a href="#">A link to a page</a></li>
<li><a href="#">A link to a page</a></li>
<li><a href="#">A link to a page</a></li>
</ul>
</li>
<li>
<a href="#" onclick="toggleDisplay('sectionThreeLinks');return false;">Click</a><span style="display:inline-block; float:right" class="icon icon-minus"></span>
<ul id="sectionThreeLinks" style="display: none;">
<li><a href="#">A link to a page</a></li>
<li><a href="#">A link to a page</a></li>
<li><a href="#">A link to a page</a></li>
<li><a href="#">A link to a page</a></li>
</ul>
</li>
</ul>
</div>
<div style="float: left">
<ul class="navigation_primary">
<li><a href>M</a></li>
<li><a href>M</a></li>
<li><a href>M</a></li>
<li><a href>M</a></li>
</ul>
</div>