HTML / CSS垂直对齐无线电旁边的两行(HTML / CSS Vertical align two lines next to radio)

编程入门 行业动态 更新时间:2024-10-24 19:16:50
HTML / CSS垂直对齐无线电旁边的两行(HTML / CSS Vertical align two lines next to radio)

我试图将两条线对齐到单选按钮的中间,如下所示。

使用CSS实现这一目标的最佳方法是什么? 我可以排在最前面,但底线是超级顽固的。 我试图不使用无线电,如果可能的话,因为它正在使用jquery插件进行重新设计。

谢谢你的帮助!

编辑:这是我一直在使用的代码:

<div> <input id="method-{{Description}}" type="radio" name="project[shipping-method]" value="{{Description}}" /> <label for="method-{{Description}}" class="pb-shipping-method-label">{{Description}} ({{DeliveryTime}}) <span>{{Price}}</span></label> </div>

I'm trying to have two lines aligned to the middle of a radio button, shown below.

What is the best way to achieve this with CSS? I can line up the top line but the bottom line is super stubborn. I'm trying not to float the radio, if possible, as it is being restyled using a jquery plugin.

Thanks for your help!

EDIT: here's my code that I've been working with:

<div> <input id="method-{{Description}}" type="radio" name="project[shipping-method]" value="{{Description}}" /> <label for="method-{{Description}}" class="pb-shipping-method-label">{{Description}} ({{DeliveryTime}}) <span>{{Price}}</span></label> </div>

最满意答案

两个div,一个拿着收音机,一个拿着文字。 将radio div的line-height设置为等于text div的height 。 还要在收音机本身添加vertical-align:middle 。

这是一个演示: http : //jsfiddle.net/AlienWebguy/JffCD/

Two divs, one holding the radio and one holding the text. Set the line-height of the radio div to equal the height of the text div. Also add a vertical-align:middle to the radio itself.

Here's a demo: http://jsfiddle.net/AlienWebguy/JffCD/

更多推荐

本文发布于:2023-07-30 01:31:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1321402.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:无线电   两行   CSS   HTML   radio

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!