Can anyone advise on an accordion for the left nav on the category pages? Is there a possibility to do this purely using CSS? Or do I need jquery?
-
you can't get the onclick event by css, you need javascript to do this.– MeenakshiSundaram RCommented Sep 26, 2015 at 18:02
-
you are using cusom rwd theme or else– Magento 2Commented Sep 26, 2015 at 18:04
-
Correct I'm using a custom RWD theme...– YorkieMagentoCommented Sep 26, 2015 at 20:28
-
1@MeenakshiSundaram, this is not true at all and there are very many ways of building a fully functional accordion menu without jQuery (or any script) at all.– David LernerCommented Sep 28, 2015 at 1:33
1 Answer
You can accomplish this with any combination of Pure CSS alone, CSS + jQuery/Javascript, jQuery/Javascript (although this would be relatively pointless, considering you'd still need the CSS to style the way the menu looks).
Here are a few examples of Pure CSS accordion menus:
- http://codepen.io/anzjoy/pen/bahAv
- http://cssdeck.com/labs/content-accordion-in-pure-css3
- http://codepen.io/flizoid/pen/EnHed
- http://codepen.io/oknoblich/pen/tKfab
And a few examples of jQuery + CSS accordion:
While you can do more with jQuery, it's preferable not to use it if you have the luxury. In this case, assuming the mention CSS accordion menus fulfil your requirements, why should you burden your visitors and their browsers with the unnecessary script?
Note: The only instance where jQuery might be preferable is if you intend on supporting pre-IE9 browsers and some modern CSS features are not fully supported.