سؤال

I'm just wondering if it's possible to close sub-menu by tapping on it's name again? I'm doing a web-site horizontal menu with few sub-menus in it. On li:hover - sub-menu opens, and closes if another element was touched. But how to close same menu by tapping same List item? Is it possible to do this on pure CSS3?..

Thanks.

هل كانت مفيدة؟

المحلول

You can (mis)use an input (checkbox) element with the CSS attribute :checked, so something like:

.input-list-item + .list-below { display: none; }
.input-list-item:checked + .list-below { display: block; }  

Support in modern browsers and (with the right doctype) IE9+

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top