Styling select fields and options
P粉924915787
P粉924915787 2023-09-08 11:28:13
0
2
355

I have a multi-select field with a lot of options and I want to display them as small chunks instead of displaying a long list of items. I can do this by setting "options" to "display: inline-block", but I have an issue where the options don't go into the second line when they reach the container boundary, but are hidden behind the container.

As you can see here, we cut off the last item and all the following items are invisible.

.column-select { width: 100%; } .column-select option { display: inline-block; padding: 5px 10px; border-radius: 5px; background: #2b3035; color: #FFFFFF; margin: 5px; outline: none; }

Is there a way to have the options passed to the second line instead of passed behind the container?

P粉924915787
P粉924915787

reply all (2)
P粉545956597

By giving the container stylesdisplay: flexandflex-wrap:wrap;, options will automatically wrap to the next line limit when the container width is reached.

The following is the updated CSS code:

.column-select { width: 100%; display: flex; flex-wrap: wrap; } .column-select option { display: inline-block; padding: 5px 10px; border-radius: 5px; background: #2b3035; color: #FFFFFF; margin: 5px; outline: none; }
    P粉226667290

    It seems impossible to do this with the select element. I changed the field structure from "select>options" to "ul>li>checkbox" so that I could style the box and eachlithe way I wanted. After hiding the checkbox using "appearence: none" the result is the same as the selected one.

      Latest Downloads
      More>
      Web Effects
      Website Source Code
      Website Materials
      Front End Template
      About us Disclaimer Sitemap
      php.cn:Public welfare online PHP training,Help PHP learners grow quickly!