CSS accordion causing radio button to malfunction

I am encountering an issue with a radio button placed inside a css accordion. It seems like the styling from the accordion might be causing interference with the functionality of the radio button. Additionally, as the accordion is constructed using a checkbox it could also be contributing to the problem. Furthermore, I have incorporated some dojo controls within the accordion where some are functioning correctly while others are not. Below is the code snippet: The first radio button located outside the accordion is working perfectly.

HTML:

<input type="radio" name="colors" value="green" />Green <!--this works fine-->
<input type="radio" name="colors" value="red" />Red
<section id="accordionMTF">
    <div>
        <div style="width: 450px;
                              height: 80px"></div>
        <input type="checkbox" id="checkMTF-1" checked="checked" />
        <label for="checkMTF-1">Input System Info</label>
        <article>
            <input type="radio" name="colors" value="green" />Green  <!--this doesnt work-->
            <input type="radio" name="colors" value="red" />Red</article>
    </div>
    <div>
        <input type="checkbox" id="checkMTF-2" />
        <label for="checkMTF-3">Input Marking Information</label>
        <article>
            <p style="width: 450px;
                              height: 400px">Fill out form</p>
        </article>
    </div>
    <div>
        <input type="checkbox" id="checkMTF-3" />
        <label for="checkMTF-4">Complete and Submit</label>
        <article>
            <p style="width: 450px;
                              height: 400px">Fill out form</p>
        </article>
    </div>
</section>

css: /Mark Ticket Form Accordion/

#accordionMTF input {
        display: none;
    }
    #accordionMTF label {
        background: #eee;
        border-radius: .25em;
        cursor: pointer;
        display: block;
        margin-bottom: .125em;
        padding: .25em 1em;
        z-index: 20;
    }
    #accordionMTF label:hover {
        background: #ccc;
    }
    #accordionMTF input:checked + label {
        background: #ccc;
        border-bottom-right-radius: 0;
        border-bottom-left-radius: 0;
        color: white;
        margin-bottom: 0;
    }
    #accordionMTF article {
        background: #f7f7f7;
        height:0px;
        overflow:hidden;
        z-index:10;
    }
    #accordionMTF article p {
        padding: 1em;
    }
    #accordionMTF input:checked article {
    }
    #accordionMTF input:checked ~ article {
        border-bottom-left-radius: .25em;
        border-bottom-right-radius: .25em;
        height: auto;
        margin-bottom: .125em;
    }

I have created a fiddle which can be viewed here: here

Thank you!

Answer №1

By maintaining the same HTML structure, you can easily adjust your CSS to achieve the desired look. Take a look at this CSS snippet:

#accordionMTF > div > input[type='checkbox'] {
    display : none;
}

This method showcases an innovative way to create an accordion without relying on JavaScript. Additionally, consider enhancing it further with CSS3 animations for added flair.

It's worth noting that there is a bug related to incorrect values in the for attribute of your labels.

To see this approach in action, check out the live example on JSFiddle here.

Answer №2

The creator of the accordion component has made the decision to conceal ALL input elements (!?)

#accordionMTF input {
    display: none;
}

Instead, a more reasonable approach would be to assign a class (.hidden) to the required inputs for the accordion functionality and use that class as a selector rather than hiding all inputs indiscriminately:

<input type="checkbox" class="hidden" id="checkMTF-1" class="hidden" />

.hidden {
    display: none;
}

VIEW WORKING EXAMPLE

Answer №3

Let me explain why:

.accordionMTF input {
        visibility: hidden;
    }

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

Get every possible combination of a specified length without any repeated elements

Here is the input I am working with: interface Option{ name:string travelMode:string } const options:Option[] = [ { name:"john", travelMode:"bus" }, { name:"john", travelMode:"car" }, { name:"kevin", travelMode:"bus" ...

What is preventing my CSS variables from functioning in my Vue component that is utilizing SASS?

Currently, I am working with sass and vue version-3. Within one of my components, the following code is present: HelloWorld.vue : <template> <div class="greetings"> <h1>{{ msg }}</h1> <h3> You’ve succe ...

Triggering a jQuery event when a CSS property is altered

My current approach involves utilizing the .animate method to shift a div 100px to the right in just 1 second. Essentially, this means moving by 1px every 10ms. I am now exploring whether there exists an event that could be triggered after each individual ...

Is there a way to retrieve the aria-label attribute value from this specific WebElement?

When utilizing Java Selenium, I have access to a WebElement object that corresponds to the following HTML node: <td role="gridcell" class="mat-calendar-body-cell ng-star-inserted" style="width: 25%; padding-top: 7.14286%; paddin ...

The useMutation function trapped in an endless loop

I've been encountering an issue while running a query to save an entity in the database using usemutation. The saveVisa() mutation seems to be stuck in an infinite loop, creating the same element multiple times without any clear reason. import {React, ...

The bootstrap carousel seems to be malfunctioning and instead displaying as background images

As someone who is new to coding, I have been attempting to create a slider on Bootstrap, but it seems to be displaying more like a background than an actual slider. Here is an excerpt of my HTML code: <body> <div class="navbar navbar-default ...

The carousel feature results in the screen jumping to the top of the page when switching slides

View GitHub for Minimum Reproducible Example (Images are not displayed in this example, but it does not affect the issue being discussed) Challenge: The screen automatically scrolls to the top of the page every time the slide index changes. This occurs w ...

Finding the precise Time zone with date-fns: A comprehensive guide

I've implemented a date pipe using the date-fns library for formatting dates. Here is the code: date.pipe.ts import { Pipe, PipeTransform } from '@angular/core'; import { format } from 'date-fns'; @Pipe({ name: 'formatDate ...

Tips for effectively deleting a flash object from an HTML page

I recently created a website with AJAX (using jquery) for navigation purposes. The pages on the site slide smoothly, and I have been using remove() to get rid of the old page. Everything was working fine until I encountered an issue where the browser cras ...

Exploring the issue: Using Safari, setting a min-height of 100% does not function properly within a flex-grow child

When testing my code in Chrome, Edge, and FireFox, I noticed that the innermost div fills its parent correctly using min-height: 100%. However, Safari does not display the same behavior. The green div is not completely covered by its children as expected. ...

The React Native File generator

Currently, we are utilizing redux actions in our web project. In an effort to share logic between web and native applications, we have integrated these actions into our react native project with the intention of only having to modify the components. One o ...

When the parent component in React JS rerenders, the props are not automatically passed down to the child

I have come across similar questions in the past, but I have not found any answers that directly address the issue I am facing in my scenario. In my case, there is a parent component that passes a property to a child component's state. Depending on t ...

Can you explain the functionality behind the expression "this.method.bind(this)"?

Encountered the code for the first time: var Controller = function($scope){ this._scope = $scope; } Controller.$inject = ['$scope']; Controller.prototype.augmentScope = function() { this._scope.a = { methodA: this.methodA.bind( ...

What could be causing the child view to not display the AJAX result?

An AJAX call is being made in the following manner: @Ajax.ActionLink("My Schedule", "GetSchedule", "Schedule", new { selectedDate = strToday}, new AjaxOptions { UpdateTargetId = "theTimes", InsertionMode = InsertionMode.Replace, HttpMethod = "GET" }) Th ...

In NextJS 12, an UnhandledPromiseRejectionWarning occurs when trying to reference the TextEncoder which is not defined

Currently, I am working on developing a Spotify clone using NextJS 12 along with a Tailwind CSS template. To initiate the project, I executed the following command: npx create-next-app -e with-tailwindcss spotify-2. The project was successfully created, b ...

I need assistance with displaying this array either using CSS styling or in table format. Can someone please

Seeking assistance to display this data in table format using tables, css, or bootstrap. Can anyone help? Utilized PHP Code: $url = "http://some-website.com/api/message"; $ch = curl_init($url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $content = cur ...

Navigating the FormSpree redirect: Tips and tricks

I recently set up my website on Github Pages and wanted to integrate a free contact form from FormSpree. However, I encountered an issue where after submitting the form, it redirected to a different website, which was not ideal. After researching online, I ...

Is it feasible to develop an asynchronous function in Node.js that executes concurrently?

My objective is to simultaneously execute the longRunnigTask and quickTask functions: function longRunnigTask() { return new Promise((resolve) => { console.log('longRunnigTask started'); for (let i = 0; i < 999999999; i+ ...

Using Javascript Timers in an ASP.NET AJAX application with the pageLoad() function

function initiatePageLoad() { clearTimeout("MessagesTimer"); clearTimeout("NotificationsTimer"); var MessagesTimer = setTimeout("CheckMessages()", 15000); var NotificationsTimer = setTimeout("CheckNotifications()", 15000); } I've be ...

AngularJS - displaying a notification when the array length is empty and customizing the visibility to conceal the default action

I've been working on an Angular project where I display a loading circle that disappears once the content is loaded. This circle is simply a CSS class that I call from my HTML only when the page first loads, like this: Actually, the circle consists o ...