我正在为学校项目创建一个测验网站。 每当选择正确答案(input type=radio)我希望与其相邻的线变为green ,当选择了错误答案时,我希望线变为red 。
有没有办法只使用css而不是JavaScript 。
I am creating a quiz website for a school project. Whenever a correct answer is selected (input type=radio) then I want the line adjacent to it to become green and when an incorrect answer is selected I want the line to become red.
Is there any way to do this using css only and not JavaScript.
最满意答案
在输入中有一些属性表明它是正确的选项,然后使用[attribute="value"]在CSS中监听它,然后使用某种运算符(如+ )选择下一个标记(p等)
JSfiddle演示
Have some attribute in your input indicating that it's the right option and then listen for it in CSS using the [attribute="value"] then select the next tag (p etc.) with some kind of operator (like +)
JSfiddle demo
更多推荐
发布评论