1

I am trying to simulate an accordion menu in CSS.

I cannot use javascript for a variety of reason, so its CSS only.

Is there some simple code to show/hide a div on the click of a button

3
  • No, you can use :hover though. Commented Jun 6, 2012 at 15:01
  • Could you specify what you mean by 'accordion menu'? Like a menu with several children/sub-options which extend when you hover over it? Commented Jun 6, 2012 at 15:24
  • What html markup do you want to use for it? Commented Jun 6, 2012 at 17:43

3 Answers 3

6

If you're looking for a pure CSS accordion this article and demo may help...

https://catalin.red/dist/uploads/2011/05/css3-accordion.html

https://catalin.red/css3-accordion/

Sign up to request clarification or add additional context in comments.

1 Comment

This is a nice solution, I think I have to look into :target ;)
1

I believe it can be done with CSS3, but not all browsers support animations. Here's the best I could find that explicitly states no Javascript.

http://featofdesign.com/stephen/2011/06/16/css3-simple-slideout-accordion-menu/

Comments

0

I don't think you can make it behave like an actual accordion without javascript.

About the best thing you could do is to make every menu option collapsed and on hover make it expand, but as soon as you hover out, the menu option will collapse again.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.