Hello all
I am struggling with creating a vertical inline collapsible menu for a site. I have had two attempts at changing the current CSS myself, adapting templates I have found but none have the desired result, where can I find additional CSS info to achieve what I need and where to input it as I have never done any CSS/HTML work before starting this job a few week ago! The menu as it appears now is correct and I have placed the correct pages as sub-menus by dragging and dropping the pages onto the correct link on the menu to create the nest/parent folder (is that the right term?) but need to adapt the stylesheet to recognise it. The submenus are disabled at the moment as the appear on top of the original menu. Current CSS looks like this (before my attempts):
/* Dynamic menu */
#navigation ul {
list-style-type: none;
margin-left:-5px;
padding:0px;
width:200px;
}
#navigation li a {
font-family: helvetica, arial, sans-serif;
text-indent: 12px;
font-size: 13px;
line-height: 18px;
color: white;
text-decoration:none;
color: #fff;
cursor: pointer;
display:block;
height:25px;
line-height: 25px;
width:100%;
}
#navigation li a:hover {
background-image: url(/images/navbg.jpg);
background-repeat: no-repeat;
}
Thanks in advance.
Matt,
not sure what exactly you are hoping for design-wise (include a link?), but this might help you out:
/* Dynamic menu */
#navigation ul {
list-style-type: none;
margin: 0;
padding: 0px;
width: 200px;
}
#navigation li {
position: relative;
}
#navigation li a {
font-family: helvetica, arial, sans-serif;
text-indent: 12px;
font-size: 13px;
line-height: 18px;
color: white;
text-decoration: none;
color: #fff;
cursor: pointer;
display: block;
height: 25px;
line-height: 25px;
width: 100%;
background: #333;
position: relative;
}
#navigation li ul {
left: -999em;
position: absolute;
}
#navigation li a:hover {
background: #666;
}
#navigation li:hover > ul {
left: 200px;
position: absolute;
top: 0;
}
Nicole - BCGurus.com | http://bcgurus.com/Business-Catalyst-Templates for only $7
Thanks for your help Nicole
Let me try and explain what I am trying to build more effectively, the current menu renders like this:
A basic version of the file structure of the menu items. Sub menu items diabled in this one to give the above appearance:
If the sub menu items, which I want to collapse in and out, are enabled then the below result occurs, a cogested menu.
What I am trying to replicate is something that follows the design in place with similar functions to: http://dev.danen.org/demo/danen/jquery/collapsible_menu.htm# Im trying out your code and think I have come up with something however when I try to edit the css code in the stylesheets folder it decides to change the code for me.
The code I have adapted from yours is:
/* Dynamic menu */
#navigation ul {
list-style-type: none;
margin-left: -5px;
padding: 0px;
width: 200px;
}
#navigation li {
position: relative;
}
#navigation li a {
font-family: helvetica, arial, sans-serif;
text-indent: 10px;
font-size: 13px;
line-height: 18px;
color: white;
text-decoration: none;
font-weight: bold;
color: #fff;
cursor: pointer;
display: block;
height: 25px;
line-height: 25px;
width: 100%;
position: relative;
}
#navigation li ul {
left: -999em;
position: absolute;
}
#navigation li a:hover {
background-image: url(/images/navbg.jpg);
background-repeat: no-repeat;
}
#navigation li:hover > ul {
left: 200px;
position: absolute;
top: 0;
}
However
When I update my stylesheet after testing in firefox's editor (although I cannot test the depth just the initial style) it just reverts back to the original, or refuses to render the changes.
Any thoughts much appreciated.
Matt
Hello matt_no7,
The css that Nicole gave you was for a drop down style menu that drops below or to the side of your menu. She didn't have all the info needed, so for the collapsing menu this will not work.
To get this to work all you would need to do is set the second unordered list to display none, then use jQuery to toggleSlide when the top level link is clicked.
Here is a jsfiddle that uses some of the code from your example site: http://jsfiddle.net/chaddidthis/swArc/4/
So basically set the second level unordered lists to display none:
#nav ul ul{ display:none; }
Then the jQuery to toggle them up and down:
$("#nav ul li a").click(function(e) { e.preventDefault(); $(this).siblings("ul").slideToggle("fast"); });
The jQuery needs to be in a ready function and inside script tags.
All of the css above this, with the absolute positioning and left -999ems, that isn't necessary and you can get rid of most of that.
Hope this helps,
Chad Smith | http://bcgurus.com/Business-Catalyst-Templates for only $7
I have also had issues with code not updating when I save and re-upload css files. Don't know if it is a BC thing or what. Seems to update eventually, but takes a long time.
Hope this helps,
Chad Smith | http://bcgurus.com/Business-Catalyst-Templates for only $7
It is that caching bug that appears often after releases etc. You probably seen it over the years more then once :)
Often it is the media server out of sync of the system server. As you probably know things like the CSS etc is not all in the same place as the system stuff and BC serves cached versions for performance. When you upload new files the cache is supposed to be flushed as it were and the a new cache file generated.
That's a bit laments terms for everyone so not 100% accurate but you get the idea and get to see what possible issues can occur.
Thanks Chad this looks good, your example is pretty much exactly what I am after, want to adapt the styling slightly. When inserting the jquery you have supplied how is best to go about this? Should I make a new stylesheet and link to it or can I put it in the current style after the #navigaion code? To be honest I have no idea how its best used as the dynamic menu builder seems to do all the code inserting.
The changes from the css I adapted from Nicoles came through at some point before I got into work this morning. The changes had made a drop down to the right of the main menu although it was not really visible because of the layout of the page. Guess it did just needed some time.
Thanks all
Hello matt_no7,
To use the jQuery provided, place the jQuery from my jsfiddle link between script tags:
<script type="text/javascript">
//code goes here//
</script>
Then wrap your dynamic menu in a div with an ID of nav:
<div id="nav">
{module_menu,XXXXXX}
</div>
or if your menu is already wraped by a div you can just change the jQuery to match.
Hope this helps,
Chad Smith | http://bcgurus.com/Business-Catalyst-Templates for only $7
Sorry Chad, while that bit makes sense, as I am unfamiliar with BC, I don't know how to affect the entire code of the menu. I just put the menu items on the dynamic menu building function and that builds the menu html into the template for the site. I only know how to edit the stylesheet that has the original css from above. Which I have now edited to my own highly unefficient design but is not vey useful (see below). I have the original though.
I think my menu is wrapped in a div already: #navigation. With a css class of navquarsh (not sure what that means exactly). Dont mean to sound ignorant but I am really new to this. The site is www.quarsh.com btw.
<!-- Column 2 start LEFT NAVIGATION-->
<div id="navigation">
<script type="text/javascript" src="/CatalystScripts/Java_DynMenusSelectedCSS.js"></script><!-- Dynamic Menu Begin CSS Output --><div id="cat_642957_divs"><ul id="nav_642957"><li class="navquarsh" style="width:190px;height:30px;"><a href="/home">Home</a></li><li class="navquarsh" style="width:190px;height:30px;"><a href="/quarsh_services.html">Quarsh Services</a><ul id="navsub_642957_1040688"><li class="navquarsh" style="width:190px;height:30px;"><a href="/recruitment_process_improvement.html">Recruitment Improvement</a></li><li class="navquarsh" style="width:190px;height:30px;"><a href="/executive_search.html">Executive Search</a></li><li class="navquarsh" style="width:190px;height:30px;"><a href="rpo.html">RPO</a></li><li class="navquarsh" style="width:190px;height:30px;"><a href="/talent_warehousing.html">Talent Warehousing</a></li></ul></li><li class="navquarsh" style="width:190px;height:30px;"><a href="/why_quarsh.html">Why Quarsh</a></li><li class="navquarsh" style="width:190px;height:30px;"><a href="/experience.html">Experience & Case Studies</a></li><li class="navquarsh" style="width:190px;height:30px;"><a href="http://www.quarsh.com/quarsh_news_media_jobs.html">News, Media and Jobs</a></li><li class="navquarsh" style="width:190px;height:30px;"><a href="/contact.html">Contact Us</a></li></ul></div><script type="text/javascript">catSetSelectedCSSItem('nav_642957');</script><!-- Dynamic Menu End CSS Output -->
</div>
Right, so you got the drop down style menu working. To get the collapsable menu you don't need to edit your dynamic menu other than "Quarsh Services" will not be a link to a page any longer, because you want it to show the other links when you click it - not go to a page.
Then just place the js on the template using the script tags and the code from jsfiddle. I would place it on the bottom of the page, just above the </body> tag, you will also need to add jQuery to your page - here is a CDN link:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js" type="text/javascript"></script>
Hope this helps,
Chad Smith | http://bcgurus.com/Business-Catalyst-Templates for only $7
North America
Europe, Middle East and Africa
Asia Pacific