【问题标题】:html label radio works on desktop and emulator but not iOS Safarihtml 标签收音机适用于桌面和模拟器,但不适用于 iOS Safari
【发布时间】:2017-03-08 19:49:16
【问题描述】:

我很难调试这个,但基本上我有一堆复选框,看起来都像下面的例子:

<div class="column">
  <input id="radio-10" type="radio" class="radio-custom" value="3">
  <label for="radio-10" class="radio-custom-label"><br>
  <p>Long time employed by the same employer</p></label>
</div>

如果我在 Chrome 的模拟器中单击它,它可以正常工作。如果我在桌面上单击它,它工作正常(框被选中)。在实际的 iPhone 上,您的复选框永远不会被选中。

这里有什么突出的吗?或类似的问题。

也不确定它是否重要(因为它适用于桌面和模拟器,但不适用于移动设备)这些都是使用 vue.js 动态创建的,如下所示:

<li v-for="(question, questionIndex) in questions">
                        <h2>{{ question.question }}</h2>

                        <div class="columns">

                          <div class="column" v-for="(answer, index) in question.answers">
                            <input 
                                :id=" 'radio-' + answer.id" 
                                :value='answer.points' 
                                class="radio-custom"  
                                v-model.number="chosen[ questionIndex ]" 
                                type="radio"
                            >
                            <label :for=" 'radio-'+ answer.id" class="radio-custom-label"><br><p>{{ answer.answer }}</p></label>
                          </div>

                        </div>

                        <div class="control is-grouped">
                            <p class="control">
                                <button class="button is-primary" 
                                        v-if="questionIndex != 0" 
                                        @click.prevent="back">
                                        Back
                                </button>
                            </p>

                            <p class="control">
                                <button class="button is-primary" 
                                        @click.prevent="next">
                                        Next
                                </button>
                            </p>

                        </div>

                    </li>

更新:

我删除了 acutal 单选按钮上的不透明度,可以看到它正在工作,但 css 没有添加复选标记。特别是这些行看起来像:

 `.radio-custom:checked + .radio-custom-label:before {
    content: "\f00c";
    font-family: 'FontAwesome';
    color: $green;
    font-size: 25px;
}
`

完整的 CSS

.checkbox-custom, .radio-custom {
    opacity: 0;
    position: absolute;   
}

.checkbox-custom, .checkbox-custom-label, .radio-custom, .radio-custom-label {
    display: inline-block;
    vertical-align: middle;
    margin: 5px;
    cursor: pointer;
}

.checkbox-custom-label, .radio-custom-label {
    position: relative;
}

.checkbox-custom + .checkbox-custom-label:before, .radio-custom + .radio-custom-label:before {
    content: '';
    background: #fff;
    border: 2px solid #ddd;
    display: inline-block;
    vertical-align: middle;
    width: 40px;
    height: 40px;
    padding: 2px;
    margin-right: 10px;
    text-align: center;
}

.checkbox-custom:checked + .checkbox-custom-label:before {
    content: "\f00c";
    font-family: 'FontAwesome';
    background: rebeccapurple;
    color: #fff;
    font-size: 25px;
}

.radio-custom + .radio-custom-label:before {
    border-radius: 50%;
}

.radio-custom:checked + .radio-custom-label:before {
    content: "\f00c";
    font-family: 'FontAwesome';
    color: $green;
    font-size: 25px;
}

.checkbox-custom:focus + .checkbox-custom-label, .radio-custom:focus + .radio-custom-label {
  outline: 1px solid #ddd; /* focus style */
}

【问题讨论】:

  • 如果将key 属性添加到li 元素(如:key="questionIndex")会发生什么?
  • 什么都没有。我正在阅读有关 iOS 9 在标签内有一个元素使其无法正常工作的信息,但这也无济于事。同样,这似乎只是一个 iOS 移动问题
  • 这里的单选按钮可以在您的 iPhone 上使用吗? jsfiddle.net/bwcat0eg/2 顺便说一句,我注意到您的单选按钮上没有 name 属性。
  • @RoyJ 是的。我更新了我的问题,因为它似乎与单选按钮中的 CSS 相关,但没有反映检查

标签: html css mobile vue.js


【解决方案1】:

经过几个小时的废话,我发现它缺少 FontAwsome 字体。我在本地拥有它们,这就是为什么它只在移动设备上。

【讨论】:

    猜你喜欢
    • 2014-01-15
    • 2020-03-06
    • 2015-09-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-11-22
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多