简体   繁体   English

选中后在单选按钮下方显示文本消息

[英]Displaying text message below radio button once it is checked

I have two radio buttons side by side.After the first radio button is checked I have to display the text below it.我有两个并排的单选按钮。选中第一个单选按钮后,我必须在其下方显示文本。 I'm using this code but the text comes vertically.I want to display it horizontally.我正在使用此代码,但文本是垂直的。我想水平显示它。

 input[type=radio]:before { content: ''; display: inline-block; width: 15px; height: 15px; background: transparent; border: 2px solid #004ecb; border-radius: 50% } input[type=radio]:checked:after { content: 'Are u sure you want to select all'; display: contents; width: 15px; height: 15px; background: transparent; border: 2px solid #004ecb; border-radius: 50%; }
 <form> <label> <input type="radio" name="radio"/> Radio1 </label> <label> <input type="radio" name="radio"/> Radio2 </label> </form>

position:absolute will make it exceed the limitation of it's container (the label). position:absolute会使其超出其容器(标签)的限制。 Also why did you limit the elem to width:15px ?另外,您为什么将 elem 限制为width:15px

 input[type=radio]:before { content: ''; display: inline-block; width: 15px; height: 15px; background: transparent; border: 2px solid #004ecb; border-radius: 50% } input[type=radio]:checked:after { content: 'Are u sure you want to select all'; background: transparent; border: 2px solid #004ecb; position: absolute; }
 <form> <label> <input type="radio" name="radio"/> Radio1 </label> <label> <input type="radio" name="radio"/> Radio2 </label> </form>

Increase the width of ::after element增加::after元素的宽度

 input[type=radio]:before { content: ''; display: inline-block; width: 15px; height: 15px; background: transparent; border: 2px solid #004ecb; border-radius: 50% } input[type=radio]:checked:after { content: 'Are u sure you want to select all'; display: inline-block; height: 15px; width:200px; background: transparent; border-radius: 50%; }
 <form> <label> <input type="radio" name="radio"/> Radio1 </label> <label> <input type="radio" name="radio"/> Radio2 </label> </form>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM