CSS   发布时间:2022-04-17  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了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>

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

大佬总结

以上是大佬教程为你收集整理的css – 实现多选框全部内容,希望文章能够帮你解决css – 实现多选框所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。