输入框(Input)

文本输入及其变体

Bulma input CSS类用于input HTML元素。支持以下类型属性

  • type="text"
  • type="password"
  • type="email"
  • type="tel"

一些修饰符将影响以下效果:

<input class="input" type="text" placeholder="Text input">

颜色 #

Example

HTML

<input class="input is-primary" type="text" placeholder="Primary input">

Example

HTML

<input class="input is-link" type="text" placeholder="Link input">

Example

HTML

<input class="input is-info" type="text" placeholder="Info input">

Example

HTML

<input class="input is-success" type="text" placeholder="Success input">

Example

HTML

<input class="input is-warning" type="text" placeholder="Warning input">

Example

HTML

<input class="input is-danger" type="text" placeholder="Danger input">

大小 #

Example

HTML

<input class="input is-small" type="text" placeholder="Small input">

Example

HTML

<input class="input is-normal" type="text" placeholder="Normal input">

Example

HTML

<input class="input is-medium" type="text" placeholder="Medium input">

Example

HTML

<input class="input is-large" type="text" placeholder="Large input">

样式 #

<input class="input is-rounded" type="text" placeholder="Rounded input">

状态 #

一般的

<div class="control">
    <input class="input" type="text" placeholder="Normal input">
  </div>

悬停(鼠标放在上面)

<div class="control">
    <input class="input is-hovered" type="text" placeholder="Hovered input">
  </div>

焦点

<div class="control">
    <input class="input is-focused" type="text" placeholder="Focused input">
  </div>

载入

<div class="control is-loading">
    <input class="input" type="text" placeholder="Loading input">
  </div>

你可以通过添加 is-small, is-medium is-large 属性到control中以改变大小。

<div class="field">
    <div class="control is-small is-loading">
      <input class="input is-small" type="text" placeholder="Small loading input">
    </div>
  </div>
  <div class="field">
    <div class="control is-loading">
      <input class="input" type="text" placeholder="Normal loading input">
    </div>
  </div>
  <div class="field">
    <div class="control is-medium is-loading">
      <input class="input is-medium" type="text" placeholder="Medium loading input">
    </div>
  </div>
  <div class="field">
    <div class="control is-large is-loading">
      <input class="input is-large" type="text" placeholder="Large loading input">
    </div>
  </div>

禁用

<div class="control">
    <input class="input" type="text" placeholder="Disabled input" disabled>
  </div>

只读和静态输入框

你可以用 readonly HTML 属性,输入框看起来和普通的输入框一样,但是不能编辑且没有阴影。

<div class="control">
    <input class="input" type="text" value="This text is readonly" readonly>
  </div>

如果您还附加了静态修饰符is-static,它将删除背景、边框、阴影和水平填充,同时保持垂直间距,以便您可以轻松地在任何上下文(如水平窗体)中对齐输入。
如下第一个From后面的邮箱地址就是采用静态修饰符。

<div class="field is-horizontal">
    <div class="field-label is-normal">
      <label class="label">From</label>
    </div>
    <div class="field-body">
      <div class="field">
        <p class="control">
          <input class="input is-static" type="email" value="me@example.com" readonly>
        </p>
      </div>
    </div>
  </div>
  
  <div class="field is-horizontal">
    <div class="field-label is-normal">
      <label class="label">To</label>
    </div>
    <div class="field-body">
      <div class="field">
        <p class="control">
          <input class="input" type="email" placeholder="Recipient email">
        </p>
      </div>
    </div>
  </div>

字体图标 #

你可以附加下面的字体图标修饰符:

  • 图标在左边has-icons-left
  • 图标在右边 has-icons-right

你还需要在 icon添加修饰符:

  • icon is-left 对应于has-icons-left
  • icon is-right 对应于has-icons-right

图标大小适应于输入框大小

<div class="field">
    <p class="control has-icons-left has-icons-right">
      <input class="input" type="email" placeholder="Email">
      <span class="icon is-small is-left">
        <i class="fas fa-envelope"></i>
      </span>
      <span class="icon is-small is-right">
        <i class="fas fa-check"></i>
      </span>
    </p>
  </div>
  <div class="field">
    <p class="control has-icons-left">
      <input class="input" type="password" placeholder="Password">
      <span class="icon is-small is-left">
        <i class="fas fa-lock"></i>
      </span>
    </p>
  </div>

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

<div class="control has-icons-left has-icons-right">
    <input class="input is-small" type="email" placeholder="Email">
    <span class="icon is-small is-left">
      <i class="fas fa-envelope"></i>
    </span>
    <span class="icon is-small is-right">
      <i class="fas fa-check"></i>
    </span>
  </div>
<div class="control has-icons-left has-icons-right">
    <input class="input" type="email" placeholder="Email">
    <span class="icon is-small is-left">
      <i class="fas fa-envelope"></i>
    </span>
    <span class="icon is-small is-right">
      <i class="fas fa-check"></i>
    </span>
  </div>
<div class="control has-icons-left has-icons-right">
    <input class="input is-medium" type="email" placeholder="Email">
    <span class="icon is-left">
      <i class="fas fa-envelope"></i>
    </span>
    <span class="icon is-right">
      <i class="fas fa-check"></i>
    </span>
  </div>
<div class="control has-icons-left has-icons-right">
    <input class="input is-large" type="email" placeholder="Email">
    <span class="icon is-medium is-left">
      <i class="fas fa-envelope"></i>
    </span>
    <span class="icon is-medium is-right">
      <i class="fas fa-check"></i>
    </span>
  </div>

Variables #

Name
Type
Value
Computed Value
Computed Type
$input-color
variable
$grey-darker
hsl(0, 0%, 21%)
color
$input-background-color
variable
$white
hsl(0, 0%, 100%)
color
$input-border-color
variable
$grey-lighter
hsl(0, 0%, 86%)
color
$input-shadow
size
inset 0 1px 2px rgba($black, 0.1)
$input-hover-color
variable
$grey-darker
hsl(0, 0%, 21%)
color
$input-hover-border-color
variable
$grey-light
hsl(0, 0%, 71%)
color
$input-focus-color
variable
$grey-darker
hsl(0, 0%, 21%)
color
$input-focus-border-color
variable
$link
hsl(217, 71%,  53%)
color
$input-focus-box-shadow-size
size
0 0 0 0.125em
$input-focus-box-shadow-color
color
rgba($link, 0.25)
$input-disabled-color
variable
$text-light
hsl(0, 0%, 48%)
color
$input-disabled-background-color
variable
$background
hsl(0, 0%, 96%)
color
$input-disabled-border-color
variable
$background
hsl(0, 0%, 96%)
color
$input-arrow
variable
$link
hsl(217, 71%,  53%)
color
$input-icon-color
variable
$grey-lighter
hsl(0, 0%, 86%)
color
$input-icon-active-color
variable
$grey
hsl(0, 0%, 48%)
color
$input-radius
variable
$radius
4px
size

返回头部

问题反馈
返回顶部