I am trying to build a nested list where when the top level "li" is clicked it drops down and shows the nested list. I have found some examples online that illustrate how to do this (http://jsfiddle.net/theuideveloper/DFHWd/4/) and for the most part I can get the main js functionality to work.
My problem is that my top level list items are separated into 4 columns when I click on the first "li" it drops down my nested list directly under this "li" , pushes the second row beneath it to the right and does not span across the 4 columns, the nested list is all jumbled up in this single spot.
Here is a picture in an attempt to better explain:
Item 1 Item 2 Item 3 Item 4
-Sub Item 1 -Sub Item 2 -Sub Item 3 -Sub Item 4
Item 5 Item 6 Item 7 Item 8
So when I click Item 1 I want the nested sub Items to be displayed like above. Currently it is like this:
Item 1 Item 2 Item 3 Item 4
-Sub Item 1
-Sub Item 2
-Sub Item 3
Here is the code:
<ul class="promos">
<li class="expanded"><a href="#"><img src="{{skin url="images/category-button.png"}}" alt="" /></a>
<ul class="sub-cat">
<li.sub-cat"><a href="foo">Sub Item 1</a></li>
<li.sub-cat"><a href="foo">Sub Item 2</a></li>
<li.sub-cat"><a href="foo">Sub Item 3</a></li>
<li.sub-cat"><a href="foo">Sub Item 4</a></li>
</ul>
</li>
<li class="expanded"><img src="{{skin url="images/category-button.png"}}" alt="" /></li>
<li class="expanded"><img src="{{skin url="images/category-button.png"}}" alt="" /></li>
<li class="expanded"><img src="{{skin url="images/category-button.png"}}" alt="" /></li>
<li class="expanded"><img src="{{skin url="images/category-button.png"}}" alt="" /></li>
<li class="expanded"><img src="{{skin url="images/category-button.png"}}" alt="" /></li>
</ul>
And the css
.promos {
margin: 0 0 10px 0;
padding: 0;
width: 100%;
}
.promos:after {
content: '';
display: table;
clear: both;
}
/* Specifying the body only in order to override the .std ul li styling */
body .promos > li {
margin: 0 0 10px 0;
list-style: none;
text-align: center;
position: relative;
border: 1px solid #cccccc;
-moz-user-select: none;
-ms-user-select: none;
-webkit-user-select: none;
-o-user-select: none;
user-select: none;
}
.promos > li:last-child {
margin-bottom: 0;
}
.promos img {
max-width: 100%;
width: 100%;
}
.promos a:hover {
filter: progid:DXImageTransform.Microsoft.Alpha(Opacity=80);
opacity: 0.8;
display: block;
}
.promos span {
color: #FFFFFF;
text-transform: uppercase;
position: absolute;
display: block;
width: 100%;
top: 10%;
font-weight: 500;
font-size: 20px;
font-family: "Raleway", "Helvetica Neue", Verdana, Arial, sans-serif;
text-shadow: 1px 1px 3px #555555;
}
.promos strong {
font-weight: 600;
font-size: 26px;
display: block;
}
@media only screen and (min-width: 771px) {
.promos span {
font-size: 16px;
}
.promos strong {
font-size: 17px;
}
/* Config: Three columns + flexible gutter */
body .promos > li {
float: left;
width: 23.2142875%;
margin-right: 2.38095%; /* 30 / 1260 (margin divided by total width) */
}
.promos > li:nth-child(4n ) {
margin-right: 0;
}
}
@media only screen and (min-width: 880px) {
.promos span {
font-size: 18px;
}
.promos strong {
font-size: 24px;
}
}
The CSS defined .sub-cat is exactly the same as .promos but needed to use a different class name in order to hide it until clicked, but I need to use the same properties for text size, color etc.
Thanks!