0

I want to show content only for checked input and only one input can be checked at a time. I just want to know how to uncheck previously checked input so that only one input remain checked at a time. I want this functionality only using css not js. I know how to do this in js. This is my code for this.

input {
  display: none;
}

.content {
  padding: 5px 0px;
  margin: 0 0 1px 0;
  border-radius: 3px;
  color: hsl(240, 6%, 50%);
  font-size: 14px;
  overflow: hidden;
  height: 0;
  opacity: 0;
  transition: height 0.4s, opacity 0.4s;
}

input:checked ~ .content {
  height: 60px;
  opacity: 1;
}

Github repo: https://github.com/rishipurwar1/faq-accordion-card-main

r121
  • 2,478
  • 8
  • 25
  • 44

2 Answers2

1

use this way

<input type="radio" name="accor" id="ques-five">

https://jsfiddle.net/lalji1051/aob9mu2h/1/

Lalji Tadhani
  • 14,041
  • 3
  • 23
  • 40
1

Try this

<input type="radio" id="" name="" value="">
  • If i use radio button then I am not able to toggle checked input. – r121 Dec 28 '20 at 09:57
  • Then there may be some id issue. you should check your id name which should be same. hope so that will work for you. – Talha usman Dec 28 '20 at 10:06
  • this is my repo https://github.com/rishipurwar1/faq-accordion-card-main Could you please tell me where I am making mistake? – r121 Dec 28 '20 at 11:46