How to make radio items match width of their labels

  • Profile Image
    MeetingHabits
    Asked on December 27, 2016 at 11:04 AM

    Hello, 

    I searched the form and tried the CSS editor for a while with no luck.  How can i make the width of my radio-items auto-adjust to match the size of the label.  See attached. 

    Thanks a ton!

  • Profile Image
    ashwin_d
    Answered on December 27, 2016 at 11:22 AM

    Hello MeetingHabits,

    Please inject the following custom css code in form and see if that solves your problem:

    span.form-radio-item {

        width: 120px !important;

    }

    The following guide should help you how to inject custom css code in form:  https://www.jotform.com/help/117-How-to-Inject-Custom-CSS-Codes 

    The output of the above css is:

     

    Hope this helps.

    Do get back to us if you have any questions.

    Thank you!

  • Profile Image
    MeetingHabits
    Answered on December 27, 2016 at 11:32 AM

    Hi Ashwin, Thanks for the quick answer.  Unfortunately, that doesn't work (it then screws up other fields (image below).

    Is there any way to make the widths auto-adjust to the text?  

    If not, is there code I can use to set sizes for individual items? 

     

    Thanks!

    -Lee

  • Profile Image
    Ian
    Answered on December 27, 2016 at 11:33 AM

    Apart from what my colleague suggested, there is one more way to achieve this.

    As it appears to me that you are not looking for fix width of the radio fields so you can also opt to paste the following code in the INJECT CSS section :

    .form-radio-item{
    width: auto;
    padding-right: 15px;
    }

    This should affect all the radio fields on the form.

    Let us know if you have more questions.

  • Profile Image
    MeetingHabits
    Answered on December 27, 2016 at 11:53 AM

    Hi Ian, 

    Thanks for chiming in!!!  I've injected the CSS.  It looks great in the Advanced CSS editor preview but that doesn't carry over to the live form.  Any ideas? 

    As an FYI - i'm planning to eventually embed into a webpage using your embed code (the first option with javascript code). 

    Thanks again!

    P.s. I opened in a new browser so it shouldn'd be the browser cache. 

  • Profile Image
    Mike
    Answered on December 27, 2016 at 12:02 PM

    Please try with an !important statement.

    .form-radio-item{
    width: auto !important;
    padding-right: 15px;
    }

    Thank you.

  • Profile Image
    MeetingHabits
    Answered on December 27, 2016 at 12:51 PM

    Thanks, Mike.  That did the trick.  You guys rock!