It is unclear what you are trying to do as you are using the checkbox/radio hack to hide and show elements and usually you would hide the radio button from sight while doing this.
If you want to show the radio input in the label field then you will need to place it there absolutely and set its display to block as mentioned by TechnoBear above. You will also need to set a stacking context for the absolute child by making the parent div position:relative.
@PaulOB Thank you, I want to create a expandable radio same to same like the Amazon welcome screen but I try to search the script which related to this but I canāt find on Google. What would be code like this?
Iām not following as the code I posted is making an accordion with a radio-button (much the same as the amazon link but different styling of course)?
They both have the same function but are just styled a little differently. It should be a relatively easy matter to put your form elements inside the code I posted and add a bit of styling to match the amazon example?
What is is exactly that you canāt do?
The thread was about adding a radio button which I have shown one way for you to do it. You could indeed style the radio button differently if you styled an inner element of the label instead.
Hereās a start:
Note that the amazon site is more sophisticated and uses javascript to toggle the accordion with a fallback form post is js is disabled.
But the accordion is best in javaScript.
Mights itās funny but css accordion is too fast and not works pretty. Might you understand whatās I am saying. Thanks to @PaulOB, whoās provide the script of front look.
The amazon example you linked to and wanted to replicate has no animation and is instant. Which JS animation are you referring to?
You can adjust the speed in my example through css but to get a smoother animation we have to assume that the element will not exceed say 99em in height as you canāt animate to auto in css.
Want to add two tag inside form but when we add this, accordion is not working.
Also in that form there is the Header of accordion not become bold when we click.
Main thing is here about form. Required user can only fill one form and this is possible by form tag only.
If I apply the form elements only one form tag then user might fill both form and submit and if I add required in textbox then required all fill the text box .
Since how we add two from tag in same accordionā¦
Thatās simple styling. Just set the span to bold when the input is checked.
You can add two form tags inside quite easily.
Iāve updated the codepen:
You really need to start working these things out for yourself. I have given you the basics of what you asked for but I canāt code the whole thing for you.
Wouldnāt it make sense to simply swap the content over? It seems more logical to have the first option open by default, rather than the second, so just put the log-in information first and the sign-up option second.
If you are talking about the jQuery version and you donāt want the slideDown() or slideUp() then change those rules in the js to show() and hide() respectively. (Refer to the jQuery documentation for more info).
Show() and hide() happen instantly but I think it will be a big mistake for accessibility because users may not realise what just happened when itās instant. Itās like jumping to a new part of the page instantly and this more often than not confuses users.
The slideDown and slideUp give visual cues and allow the user to easily spot what has changed.