Jump to content

Expanding text


jwoker

Recommended Posts

I would like to create a list which, when an item is clicked, expands to show additional text regarding the item. Then if another list item is clicked, the previous text would collapse and the current items descriptive text would be shown.Is this possible with CSS? or can someone point me in the right direction.

Link to comment
Share on other sites

Is there a way for the list to close when you click on another topic? As in you had already clicked on "list" and topics appear, but when you click on "OtherList," "List's" topics closes and "OtherList's" topics are featured.List OtherList ==Click==> List OtherList1 1OL2 2OL3 3OL

Link to comment
Share on other sites

This cannot be done by CSS only, there has to be some sort of JavaScript in it :)There is a possible way indeed, not very complicated I guess.Say your list contains ten items. At initial load, none item is expanded. Each item consists of both an html element for itself, and another element for the additional information. The second element, I will call a infobox. There are two classes defined, "collapsed" and "expanded". They count for the infoboxes, and all of them are classed "collapsed" at initial load. If JavaScript detects a click on the item itself, the according infobox will get its class changed into "expanded". It even counts what infobox is expanded, so if there occures another click, the previous infobox will collapse again.So basically:-two classes for the infoboxes "collapsed" and "expanded";-statistic the last expanded infobox-on click event, collapse the previuos infobox (if present) and expand the clicked item's infoboxThats all there is to it :)Would this help you, or do you need more help with the code? (at least this should move to the JavaScript section, as you wouldn't have known by your self)

Link to comment
Share on other sites

Is there a way for the list to close when you click on another topic? As in you had already clicked on "list" and topics appear, but when you click on "OtherList," "List's" topics closes and "OtherList's" topics are featured.List      OtherList    ==Click==>  List        OtherList1                                                            1OL2                                                            2OL3                                                            3OL

Is that not the same as what was originally asked :) But like Dan said you would require javascript to do this with onclick, then it's a matter of changing the display. :)
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...