7

My understanding is that Materialize doesn't support styled multiple-select boxes - you have to specify browser-default and not use Materialize styling. (correct me if I'm wrong)

So I've tried to make an equivalent with Materialize dropdown with checkboxes inside the dropdown like this:

<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>

But there's a glitch in how this gets rendered. The text and boxes gets offset by half a line downward, so the highlighting hover effect highlights a rectangle that overlaps two different options. Is there any way to correct this glitch?

Here's a screenshot. It's not the same content as the example code above but it's the same dropdown-checkbox structure.

screenshot

stevenw00
  • 1,155
  • 1
  • 13
  • 22
Toby 1 Kenobi
  • 4,717
  • 2
  • 29
  • 43

2 Answers2

0

My workaround has been to put each checkbox in its own div inside the dropdown rather than using the dropdown list structure

<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>

It doesn't have the hover effect, but it works.

Toby 1 Kenobi
  • 4,717
  • 2
  • 29
  • 43
0
[type="checkbox"]+label {
    display: inline;
}
Emile Bergeron
  • 17,074
  • 5
  • 83
  • 129