simple_form_for rails radio button inline

后端 未结 6 1343
半阙折子戏
半阙折子戏 2021-01-30 23:26

I am trying to get my buttons to display inline and also have a default value because it can\'t be blank. I am usingplataformatex/simple_form and bootstrap.

= f.         


        
6条回答
  •  面向向阳花
    2021-01-30 23:45

    The above answer might have not worked because I'm not using Bootstrap. But there are other ways. I slapped a div with class="radio-buttons" around the buttons and label manually. Then I added this to my style sheet (SASS):

    .radio-buttons {
      margin: .5em 0;
      span input {
        float: left;
        margin-right: .25em;
        margin-top: -.25em;
      }
      #this grabs the MAIN label only for my radio buttons 
      #since the data type for the table column is string--yours may be different
      label.string { 
        margin-bottom: .5em !important;
      }
    
      clear: both;
    }
    
    .form-block {
      clear: both;
      margin-top: .5em;
    }
    
     .radio-buttons span {
      clear: both;
      display:block;
     }
    

    This will make the radio buttons inline on ALL frameworks, though this is tweaked to look the best for Zurb Foundation. ;)

提交回复
热议问题