The following code use a script to toggle/uncheck a radio when clicked a second time on the same.
My question is how do I do this using CSS only?
If the effect does not need to be persistent, you can achieve something similar playing with :focus instead of using radio buttons.
To make an element focusable, set the tabindex attribute to an integer. Use a negative one if you don't want the element to be reached via sequential focus navigation (pressing the "tab" key).
.container {
display: flex;
flex-wrap: wrap;
max-width: 660px;
}
.container > .img {
flex: 1;
position: relative;
}
.container > .img > .unselect {
display: none;
position: absolute;
top: 0; right: 0; bottom: 0; left: 0;
}
.container > .txt {
display: none;
order: 1;
flex-basis: 100%;
}
.container > .img:focus > .unselect,
.container > .img:focus + .txt {
display: block;
}
Recipe nr 1
Recipe nr 2
Recipe nr 3