February 10, 20251 yr Hello, Using CSS and radio buttons is it possible to highlight multiple td's / column when one of the radio's is selected? Thanks, Wayne
February 10, 20251 yr Yes - you just need a javascript listener. Each column will have it's own ID/class. The listener checks which option is selected and changes the CSS for the selected option using the ID/class. However. I wouldn't use a table for this as it won't work on a phone (which is the device many use).
February 10, 20251 yr The other alternative is to make the whole column a radio button. You wouldn't be able to have the full width headings but you would be able to just use something like: .options {display: grid; grid-template-columns: 32% 32% 32; grid-gap: 2%; } .options input[type="radio"] { opacity: 0; position: fixed; width: 0; } .options label { display: inline-block; text-align: center; line-height: 30px; font-size: 12px; font-weight: 900; background-color:#cce6ff; color: #164C81; cursor: pointer; } .options label:hover, .button input[type="radio"]:checked + label {background-color:#164C81;color:#FFFFFF;}
February 11, 20251 yr If the input element is a direct child of the wrapping div, then there's no need for any javascript or complex css rules, you can just target it using the :has() modifier Just quickly did this in a couple of minutes as an example (May need to copy the link into a new tab) https://codepen.io/jpeters8889/pen/yyLLOwW
February 11, 20251 yr I'd forgotten about :has. That's an even better solution. @Waynede1986 - bin the table and your problems are solved.
February 11, 20251 yr Author If I bin the table can I still have the full width heading in between benefits? Happy to try anything, and appreciate all the help and advice. I saw jpeters8889 was using the :has Edited February 11, 20251 yr by Waynede1986
February 11, 20251 yr 18 minutes ago, Waynede1986 said: If I bin the table can I still have the full width heading in between benefits? Probably not. But you really don't want to use tables. The main reason being it won't fit on a phone.
February 11, 20251 yr Author I have this codepen https://codepen.io/HGWayne/pen/emYYdOW which within my solution does this when selecting a radio: Is there a way to make each radio specific to each column? Mobile devices will have it's own layout with the table hidden. Thanks
Create an account or sign in to comment