【问题标题】:Changing space between two radio buttons from the same group更改同一组中两个单选按钮之间的间距
【发布时间】:2021-04-24 00:19:19
【问题描述】:

是否可以更改两个水平单选按钮之间的间距?两个按钮都在同一个组中,我想将右边的按钮(“清除选择”)向右移动,以便与下面另一组中的按钮匹配。

                <v-radio-group v-model="consent.newselection2"
                row
                   >
                  <v-radio
                   class="radio"
                    color="yellow"
                    v-for="item in conclusionnewitems2"
                    :rules="rules"
                    :key="item"
                    :label="item.label"
                    :value="item.value"
                  ></v-radio>
                </v-radio-group>
conclusionnewitems2: [
       { label: "Website", value: {'var1':"On our website", 'var2': "included on our website"}},
       { label: "Clear slelection", value: "null"},
],

【问题讨论】:

    标签: javascript html css vue.js radio-button


    【解决方案1】:

    看起来您正在使用像 Vuetify(或类似的东西)这样的框架,但只要它不会覆盖您的样式,您就可以使用一个类和一些 CSS:

    <template>
      <v-radio class="radio padding-left" .../>
    </template>
    
    <style>
    .padding-left {
      padding-left: 4px; // or however much you want
    }
    </style>
    

    ...或者使用简单的样式属性:

    <template>
      <v-radio style="padding-left: 4px;" .../>
    </template>
    

    编辑:只移动一个(例如 2 号): 我喜欢在循环中使用索引,并像这样添加一个动态类:

    <template>
      <v-radio 
        v-for="(item, idx) in conclusionnewitems2"
        class="radio"
        :class="idx === 1 ? 'padding-left' : ''" 
        ...
      />
    </template>
    

    这意味着只有第二个 (idx == 1) 会有 padding-left。

    【讨论】:

    • 感谢您的回答。问题是它移动了两个单选按钮。我正试图移动正确的,但因为他们在同一个组中,这被证明是困难的。是的,我正在使用 vuetify
    • 我更新了答案 :) 请注意,您可以在动态类属性中使用 idx !== 0 或任何其他布尔检查来检查这种三元运算符。
    猜你喜欢
    • 1970-01-01
    • 2020-04-06
    • 2013-01-07
    • 2022-01-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-06-13
    相关资源
    最近更新 更多