How can I get input radio elements to horizontally align?

后端 未结 4 1756
难免孤独
难免孤独 2020-12-31 01:34

I want these radio inputs to stretch across the screen, rather than one beneath the other:

HTML



        
4条回答
  •  隐瞒了意图╮
    2020-12-31 02:14

    In your case, you just need to remove the line breaks (
    tags) between the elements - input elements are inline-block by default (in Chrome at least). (updated example).

    Always
    Never
    Cost Change
    

    I'd suggest using elements, though. In doing so, clicking on the label will check the element too. Either associate the 's for attribute with the 's id: (example)

    
    
    
    
    
    
    
    
    

    ..or wrap the elements around the elements directly: (example)

    
    
    
    

    You can also get fancy and use the :checked pseudo class.

提交回复
热议问题