HTML accordion control made purely out of css. No JS !!
Any accordion would definitely need some JS function
The following accordion uses input type="radio" and the ':checked + div' CSS selector to collapse and expand content.
How does it work?
The title of each collapsible is a label which has the attribute for="collapsible-1" to trigger the radio button collapsible-1.
Clicking the label checks the corresponding radio button. The div following the radio button is expanded as per the CSS code shown above [this collapses the rest of the divs automatically because its a radio button group, selecting one un-selects the other radio by default].
A radio button is added say collapse-all which is isolated and is not associated with any collapsible
Each 'x' is a label at top right of the collapsible which triggers this collapse-all radio.
Since this radio button is not associated with any collapsible, nothing expands and all other collapsible are collapsed automatically.
The CSS accordion:
Lorem ipsum dolor sit amet, magna ante erat lacinia integer nunc amet, dolorem donec id convallis sit. Dui ante, facilisis nulla mauris diam, quis donec wisi, curabitur eleifend dignissim, non sed libero esse et amet. In vivamus mauris amet, eget amet
ipsum sed fermentum vestibulum, sed dui auctor nunc eros. Et massa sit dui nullam, neque pellentesque vitae dolor ut rutrum, aliquam vel lectus duis, morbi sagittis. In aenean, mi mauris, sit varius velit id arcu dictum, nulla placerat fringilla
Lorem ipsum dolor sit amet, magna ante erat lacinia integer nunc amet, dolorem donec id convallis sit. Dui ante, facilisis nulla mauris diam, quis donec wisi, curabitur eleifend dignissim, non sed libero esse et amet. In vivamus mauris amet, eget amet
ipsum sed fermentum vestibulum, sed dui auctor nunc eros. Et massa sit dui nullam, neque pellentesque vitae dolor ut rutrum, aliquam vel lectus duis, morbi sagittis. In aenean, mi mauris, sit varius velit id arcu dictum, nulla placerat fringilla
Lorem ipsum dolor sit amet, magna ante erat lacinia integer nunc amet, dolorem donec id convallis sit. Dui ante, facilisis nulla mauris diam, quis donec wisi, curabitur eleifend dignissim, non sed libero esse et amet. In vivamus mauris amet, eget amet
ipsum sed fermentum vestibulum, sed dui auctor nunc eros. Et massa sit dui nullam, neque pellentesque vitae dolor ut rutrum, aliquam vel lectus duis, morbi sagittis. In aenean, mi mauris, sit varius velit id arcu dictum, nulla placerat fringilla
Windows style buttons with hover and click effect purely in CSS. Windows Classic, WindowsXP and Windows 7 buttons See the Pen Windows Buttons by Jones Vinoth Joseph ( @jo_Geek ) on CodePen .
This is another element of web page, which normally requires some script. This is somewhat related to my last post " Pure CSS Collpasible Accordion ", where I used a 'radio button' to manipulate the collpase and expanding of panels. Same thing here, this time its a 'checkbox' and a 'label' which collapses and expands the navbar when screen size less than 600. Note: Refer to the previous post to see how 'radio button' and 'label' work together. A big nav [Desktop View] A collapsed nav [Mobile view] Full HTML + CSS code
Comments
Post a Comment