【问题标题】:Materialize multiple-select boxes实现多选框
【发布时间】:2015-10-25 21:49:29
【问题描述】:

我的理解是 Materialize 不支持样式化的多选框 - 您必须指定浏览器默认值并且不使用 Materialize 样式。 (如果我错了,请纠正我)

因此,我尝试使用 Materialize 下拉菜单与下拉列表中的复选框进行等效,如下所示:

<a class='dropdown-button btn-flat' href='#' data-activates='topics_dropdown' data-hover="true">
Relates to topics...</a>
<ul id='topics_dropdown' class='dropdown-content'>
    <li>
      <input type="checkbox" name="report[topics][409928004]" id="report_topics_409928004" value="1" />
      <label for="report_topics_409928004">Engagement</label>
    </li>
    <li>
      <input type="checkbox" name="report[topics][669658064]" id="report_topics_669658064" value="1" />
      <label for="report_topics_669658064">Appraisal</label>
    </li>

    <!-- etc. -->

</ul>

但是渲染的方式有一个小故障。文本和框向下偏移半线,因此突出显示悬停效果突出显示重叠两个不同选项的矩形。有没有办法纠正这个故障?

这是一个屏幕截图。它与上面的示例代码的内容不同,但它是相同的下拉复选框结构。

【问题讨论】:

  • 找个小提琴搭档 :)

标签: css dropdownbox materialize


【解决方案1】:

我的解决方法是将每个复选框放在下拉列表中自己的 div 中,而不是使用下拉列表结构

<a class='dropdown-button btn-flat' href='#' data-activates='topics_dropdown' data-hover="true"> Relates to topics...</a>
<div id='topics_dropdown' class='dropdown-content'>
    <div>
      <input type="checkbox" name="report[topics][409928004]" id="report_topics_409928004" value="1" />
      <label for="report_topics_409928004">Engagement</label>
    </div>
    <div>
      <input type="checkbox" name="report[topics][669658064]" id="report_topics_669658064" value="1" />
      <label for="report_topics_669658064">Appraisal</label>
    </div>

    <!-- etc. -->

</div>

它没有悬停效果,但可以。

【讨论】:

    【解决方案2】:
    [type="checkbox"]+label {
        display: inline;
    }
    

    【讨论】:

      猜你喜欢
      • 2017-06-05
      • 1970-01-01
      • 2012-05-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-01-26
      相关资源
      最近更新 更多