Hide Show content-list with only CSS, no javascript used

前端 未结 12 1552
长发绾君心
长发绾君心 2020-11-28 23:18

I\'ve been searching for a good trick to make a Hide/Show content or a list with only CSS and no javascript. I\'ve managed to make this action:



        
12条回答
  •  挽巷
    挽巷 (楼主)
    2020-11-28 23:56

    A very easy solution from cssportal.com

    If pressed [show], the text [show] will be hidden and other way around.

    This example does not work in Chrome, I don't why...

    .show {
    	display: none;
    }
    .hide:focus + .show {
    	display: inline;
    }
    .hide:focus {
    	display: none;
    }
    .hide:focus ~ #list { display:none; }
    @media print {
    .hide, .show {
    	display: none;
    }
    }
    [hide] [show]
    1. item 1
    2. item 2
    3. item 3

提交回复
热议问题