下拉列表(Select)

对浏览器内置的选择下拉列表,相应地设置样式

select类是一个围绕 selectHTML元素的简单包装器,它为样式设计提供了更大的灵活性和对图标的支持

<div class="select">
    <select>
      <option>Select dropdown</option>
      <option>With options</option>
    </select>
  </div>

一些修饰符可以影响下来表单的如下属性:

多行选择框 #

你可以用 is-multiple 修饰符和HTML属性 multiple来得到一个多行选择框。

<div class="select is-multiple">
    <select multiple size="8">
      <option value="Argentina">Argentina</option>
      <option value="Bolivia">Bolivia</option>
      <option value="Brazil">Brazil</option>
      <option value="Chile">Chile</option>
      <option value="Colombia">Colombia</option>
      <option value="Ecuador">Ecuador</option>
      <option value="Guyana">Guyana</option>
      <option value="Paraguay">Paraguay</option>
      <option value="Peru">Peru</option>
      <option value="Suriname">Suriname</option>
      <option value="Uruguay">Uruguay</option>
      <option value="Venezuela">Venezuela</option>
    </select>
  </div>

颜色 #

Example

HTML

<div class="select is-primary">
    <select>
      <option>Select dropdown</option>
      <option>With options</option>
    </select>
  </div>

Example

HTML

<div class="select is-link">
    <select>
      <option>Select dropdown</option>
      <option>With options</option>
    </select>
  </div>

Example

HTML

<div class="select is-info">
    <select>
      <option>Select dropdown</option>
      <option>With options</option>
    </select>
  </div>

Example

HTML

<div class="select is-success">
    <select>
      <option>Select dropdown</option>
      <option>With options</option>
    </select>
  </div>

Example

HTML

<div class="select is-warning">
    <select>
      <option>Select dropdown</option>
      <option>With options</option>
    </select>
  </div>

Example

HTML

<div class="select is-danger">
    <select>
      <option>Select dropdown</option>
      <option>With options</option>
    </select>
  </div>

样式 #

你可以通过 is-rounded修饰符来得到一个圆角下拉列表。

<div class="select is-rounded">
    <select>
      <option>Rounded dropdown</option>
      <option>With options</option>
    </select>
  </div>

大小 #

select元素有 4 种大小:

Example

HTML

<div class="select is-small">
    <select>
      <option>Select dropdown</option>
      <option>With options</option>
    </select>
  </div>

Example

HTML

<div class="select is-normal">
    <select>
      <option>Select dropdown</option>
      <option>With options</option>
    </select>
  </div>

Example

HTML

<div class="select is-medium">
    <select>
      <option>Select dropdown</option>
      <option>With options</option>
    </select>
  </div>

Example

HTML

<div class="select is-large">
    <select>
      <option>Select dropdown</option>
      <option>With options</option>
    </select>
  </div>

状态 #

Bulma设置select元素的不同状态的样式。每个状态都可以作为伪类和CSS类使用:

  • :hover and is-hovered
  • :focus and is-focused
  • :active and is-active

This allows you to obtain the style of a certain state without having to trigger it.

一般的

<div class="select">
    <select>
      <option>Select dropdown</option>
      <option>With options</option>
    </select>
  </div>

鼠标悬停

<div class="select">
    <select class="is-hovered">
      <option>Select dropdown</option>
      <option>With options</option>
    </select>
  </div>

焦点

<div class="select">
    <select class="is-focused">
      <option>Select dropdown</option>
      <option>With options</option>
    </select>
  </div>

加载中

<div class="select is-loading">
    <select>
      <option>Select dropdown</option>
      <option>With options</option>
    </select>
  </div>

附带字体图标 #

你可以添加下面的修饰符:

  • icon is-left 对应于 has-icons-left
  • icon is-right 对应于 has-icons-right
<div class="control has-icons-left">
    <div class="select">
      <select>
        <option selected>Country</option>
        <option>Select dropdown</option>
        <option>With options</option>
      </select>
    </div>
    <div class="icon is-small is-left">
      <i class="fas fa-globe"></i>
    </div>
  </div>

如果控件包含图标,Bulma将确保图标保持居中,而不管控件或图标的大小。

<div class="control has-icons-left">
    <div class="select is-small">
      <select>
        <option selected>Country</option>
        <option>Select dropdown</option>
        <option>With options</option>
      </select>
    </div>
    <span class="icon is-small is-left">
      <i class="fas fa-globe"></i>
    </span>
  </div>
<div class="control has-icons-left">
    <div class="select">
      <select>
        <option selected>Country</option>
        <option>Select dropdown</option>
        <option>With options</option>
      </select>
    </div>
    <span class="icon is-left">
      <i class="fas fa-globe"></i>
    </span>
  </div>
<div class="control has-icons-left">
    <div class="select is-medium">
      <select>
        <option selected>Country</option>
        <option>Select dropdown</option>
        <option>With options</option>
      </select>
    </div>
    <span class="icon is-medium is-left">
      <i class="fas fa-globe"></i>
    </span>
  </div>
<div class="control has-icons-left">
    <div class="select is-large">
      <select>
        <option selected>Country</option>
        <option>Select dropdown</option>
        <option>With options</option>
      </select>
    </div>
    <span class="icon is-large is-left">
      <i class="fas fa-globe"></i>
    </span>
  </div>

返回头部

问题反馈
返回顶部