Tob*_*obi 7 css dropdownbox materialize
我的理解是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>
Run Code Online (Sandbox Code Playgroud)
但是如何渲染它会有一个小问题.文本和框向下偏移半行,因此突出显示悬停效果会突出显示一个与两个不同选项重叠的矩形.有没有办法纠正这个故障?
这是一个截图.它与上面的示例代码不同,但它是相同的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>
Run Code Online (Sandbox Code Playgroud)
它没有悬停效果,但它可以工作。