css – 实现多选框

我的理解是Materialise不支持样式化的多选框 – 您必须指定浏览器认值而不使用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>

但是如何渲染它会有一个小问题.文本和框向下偏移半行,因此突出显示悬停效果会突出显示一个与两个不同选项重叠的矩形.有没有办法纠正这个故障?

这是一个截图.它与上面的示例代码不同,但它是相同的dropdown-checkBox结构.

解决方法

我的解决方法是将每个复选框放在下拉列表中的自己的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>

它没有悬停效果,但它有效.

相关文章

Css3如何实现鼠标移上变长特效?(图文+视频)
css3怎么实现鼠标悬停图片时缓慢变大效果?(图文+视频)
jquery如何实现点击网页回到顶部效果?(图文+视频)
css3边框阴影效果怎么做?(图文+视频)
css怎么实现圆角边框和圆形效果?(图文+视频教程)
Css3如何实现旋转移动动画特效