Verifying one input individually in CSS at a time

Is there a way to display content only for the checked input while ensuring that only one input can be checked at a time? I am looking for a method to uncheck the previously checked input, so that only one input remains checked at any given time. Is it possible to achieve this functionality using only CSS and not JavaScript? Although I am familiar with how to do this in JavaScript, I would like to explore a CSS-only approach.

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;
}

Check out the code on Github: https://github.com/rishipurwar1/faq-accordion-card-main

Answer №2

Give this a shot

<input type="checkbox" id="" name="" value="">

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

What is the most concise way to write this Xpath?

How can I retrieve the attribute value of an element using an absolute path like this: //*[@id="main"]/div[3]/div/div/div[3]/div[23]/div/div/div[1]/div/div/span/img I would like to know how to write code in relative xpath. Can you provide guidance on that ...

Is there a way to locate classes containing underscores within them using Selenium?

Having trouble scraping a webpage with a class name containing an underscore, specifically this element: <span class="s-item__time-left">30m</span> == $0 I attempted to locate it by class name: time = driver.find_elements_class_name("s-item_ ...

Error message "Jquery smooth scrolling issue: Unable to retrieve property 'top' as it is not defined"

I'm currently working on a script for a back to top button that will be placed in the footer of my website. However, I'm running into an issue where I'm getting an error message saying "Cannot read property 'top' of undefined". Any ...

Illustration serving as a backdrop for a section

I'm currently working on a template design that includes a column on the left side with an image as the background. Within this image, I need to place form inputs, which could vary in quantity depending on the requirements. The issue I'm facing ...

Div that adjusts according to the width of an image

I have some images of a laptop and a tablet displayed on my webpage. The issue I am facing is that the div above the laptop should always match the width of the laptop. Everything looks great at full width, but problems arise when I scale down the window s ...

What is the best way to extract the delta from audio.currentTime?

I'm looking to synchronize my Three.js skeletal animation with an audio track. Typically, for animating the model, I would use the following code: var clock = new THREE.Clock(); function animate(){ var delta = clock.getDelta(); THREE.Animati ...

Tips on altering the h2 color when hovering using h2:hover:after

I'm attempting to alter the color of my h2 element using h2:hover:after. Can someone guide me on how to achieve this? Here is what I have tried so far. h2 { font-size: 25px; } h2:after { content: ""; display: block; width: 14%; padding-to ...

Discovering elements through parent in Selenium

<div> <span>First line</span> <p>Second line</p> <span>Third line</span> <p>Fourth line</p> </div> My goal is to access the elements within the div tag using CSS or XPath selector ...

Implementing Javascript to allow users to interact with a dynamic table

All user entries are captured and stored in an array. The array output should be displayed in a dynamic table which includes edit and delete options. If the number of entries exceeds 3, then the table should also have previous and next navigation options. ...

Using Slick Slider and Bootstrap CSS to display text on top of images

Currently, I am utilizing the slick slider from and I want to overlay text on top of the image. I tried using bootstrap carousel-caption, which works well with any image. However, with slick slider, it seems like the text is not at the highest level as I ...

transferring color values from C# to ASPX style class

In my .NET C# project, I am trying to pass a color value from my C# code to an ASP.NET style class. The CSS for my class is as follows: <style> div.timeline-event { color: #1A1A1A; border-color: green; background-color:#EFD5F6; display: inline-block ...

unable to connect to the web service using webview

When attempting to call a web service or display an alert, I am encountering some issues: Here is the code from my activity: mWebView = (WebView)findViewById(R.id.webViewRootAciviy); mWebView.setWebViewClient(new WebViewClient()); mWebView.setWebChromeCl ...

Exploring Angular 5's capabilities with elevate-zoom usage

Check out this amazing Jquery Image Zoom Plugin! Having some trouble with the elevate-zoom jquery plugin in my angular 5 app. Getting this error message: ERROR TypeError: this.elevatezoomBig.nativeElement.elevateZoom is not a function https://i.ssta ...

How can you modify the Bootstrap width to activate the responsive design?

I currently have the following HTML code snippet: <!DOCTYPE html> <html lang="en> <head> <title>Bootstrap Example</title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale= ...

How to vertically center the contents of two adjacent divs with automatic width?

I've experimented with a range of HTML elements and CSS styles in an effort to make this work, but without success. How can I achieve the following task? My goal is to have two side-by-side DIVs that automatically adjust their size based on the conte ...

"Troubleshooting issue with PHP code not running in a specific project within XAM

For some reason, the PHP codes are not parsing correctly and are just displaying as they are on the page. I am using xampp for this project, and all other projects on the same server are working fine. I have made sure not to use short tags like <?. I ...

What is the best way to extract basic information from a JSON object?

What is the best way to retrieve the weight value from this specific object? var prescription = "{'type':'" + $('#medi-type option:selected').val() +"',"+ "'weight':" + $('#weight').val() +","+ ...

What is the process to set a Woocommerce checkout field as optional when a checkbox is marked?

I need assistance with customizing the checkout page on Wordpress Woocommerce. Specifically, I want to make the field 'billing_name' not required if the checkbox 'buy_on_company' is checked. Currently, I have successfully hidden ' ...

The timing of the RequestAnimationFrame function varies based on the dimensions of my canvas

In my application, I have a canvas that dynamically adjusts its CSS size based on the window size. The main gameplay loop in my code looks like this: run = function(){ console.log(timerDiff(frameTime)); game.inputManage(); game.logics(); ...

The HTML select element fails to drop down over the THREE.js scene

I'm currently working on enhancing the Three.js editor for a project. editor link One of the tasks I'm tackling is adding a select element on top of the viewport in the editor. Unfortunately, the dropdown functionality of the select element isn ...