Bootstrap之表单控件状态 - 林七七

WBOY
Release: 2016-05-21 08:54:37
Original
1183 people have browsed it

Bootstrap中的表单控件状态主要有三种:焦点状态,禁用状态,验证状态。

 
一、焦点状态:该状态告诉用户可输入或选择东西
焦点状态通过伪类“:focus”以实现。
<span style="font-size: 15px;">bootstrap.css相应源码:</span>
<span style="color: #800000;">.form-control:focus </span>{<span style="color: #ff0000;">
    border-color</span>:<span style="color: #0000ff;"> #66afe9</span>;<span style="color: #ff0000;">
    outline</span>:<span style="color: #0000ff;"> 0</span>;<span style="color: #ff0000;">   //删除了outline的默认样式
    -webkit-box-shadow</span>:<span style="color: #0000ff;"> inset 0 1px 1px rgba(0,0,0,.075), 0 0 8px rgba(102, 175, 233, .6)</span>;<span style="color: #ff0000;">  //添加了阴影效果
    box-shadow</span>:<span style="color: #0000ff;"> inset 0 1px 1px rgba(0,0,0,.075), 0 0 8px rgba(102, 175, 233, .6)</span>;
}
Copy after login
使用方法:给控件添加类名“form-control”。
<span style="font-size: 15px;">eg:</span>
<span style="color: #0000ff;"><span style="color: #800000;">input </span><span style="color: #ff0000;">class</span><span style="color: #0000ff;">="form-control"</span><span style="color: #ff0000;"> type</span><span style="color: #0000ff;">="text"</span><span style="color: #ff0000;"> placeholder</span><span style="color: #0000ff;">="不是焦点状态下效果"</span><span style="color: #0000ff;">></span>
<span style="color: #0000ff;"><span style="color: #800000;">input </span><span style="color: #ff0000;">class</span><span style="color: #0000ff;">="form-control"</span><span style="color: #ff0000;"> type</span><span style="color: #0000ff;">="text"</span><span style="color: #ff0000;"> placeholder</span><span style="color: #0000ff;">="焦点状态下效果"</span><span style="color: #0000ff;">></span></span></span>
Copy after login
效果图如下所示:(焦点状态下为蓝色边框效果)
焦点状态下,file、radio、checkbox控件的效果与普通的input空间不完全一样,因为bootstrap对它们做了特殊处理。
<span style="font-size: 15px;">bootstrap.css相应源码:</span>
<span style="color: #800000;">input[type="file"]:focus,
input[type="radio"]:focus,
input[type="checkbox"]:focus </span>{<span style="color: #ff0000;">
outline</span>:<span style="color: #0000ff;"> thin dotted</span>;<span style="color: #ff0000;">
outline</span>:<span style="color: #0000ff;"> 5px auto -webkit-focus-ring-color</span>;<span style="color: #ff0000;">
outline-offset</span>:<span style="color: #0000ff;"> -2px</span>;
}
Copy after login
Copy after login
<span style="font-size: 15px;"><strong>二、禁用状态:</strong>该状态告诉用户不可以输入或选择东西</span>
Copy after login
<span style="font-size: 15px;">禁用状态是通过在表单控件上添加"disabled"属性以实现。</span>
Copy after login
<span style="font-size: 15px;">bootstrap.css相应源码:</span>
Copy after login
<span style="color: #800000;">.form-control[disabled],
.form-control[readonly],
fieldset[disabled] .form-control </span>{<span style="color: #ff0000;">
    cursor</span>:<span style="color: #0000ff;"> not-allowed</span>;<span style="color: #ff0000;">
    background-color</span>:<span style="color: #0000ff;"> #eee</span>;<span style="color: #ff0000;">
    opacity</span>:<span style="color: #0000ff;"> 1</span>;
}
Copy after login
<span style="font-size: 15px;">使用方法:在需要禁用的表单控件上加上"diabled"属性即可。</span>
Copy after login
<span style="font-size: 15px;">eg:</span>
Copy after login
Copy after login
Copy after login
Copy after login
<span style="color: #0000ff;"><span style="color: #800000;">input </span><span style="color: #ff0000;">class</span><span style="color: #0000ff;">="form-control"</span><span style="color: #ff0000;"> type</span><span style="color: #0000ff;">="text"</span><span style="color: #ff0000;"> placeholder</span><span style="color: #0000ff;">="不是焦点状态下效果"</span><span style="color: #0000ff;">></span>
<span style="color: #0000ff;"><span style="color: #800000;">input </span><span style="color: #ff0000;">class</span><span style="color: #0000ff;">="form-control"</span><span style="color: #ff0000;"> type</span><span style="color: #0000ff;">="text"</span><span style="color: #ff0000;"> placeholder</span><span style="color: #0000ff;">="表单已禁用,不能输入"</span><span style="color: #ff0000;">  disabled</span><span style="color: #0000ff;">></span></span></span>
Copy after login
<span style="font-size: 15px;">效果图如下所示:</span>
Copy after login
Copy after login

<span style="font-size: 15px;">说明:禁用状态下控件背景色为灰色,且手型变为不准输入的形状,若表单控件不使用类名"form-control",则禁用的控件只有一个不准输入的手型。</span>
Copy after login
<span style="font-size: 15px;">PS:在Bootstrap中,若fieldset设置了"disabled"属性,则整个域都处于被禁用状态。</span>
Copy after login
<span style="font-size: 15px;">eg:</span>
Copy after login
Copy after login
Copy after login
Copy after login
<span style="color: #008080;"> 1</span> <span style="color: #0000ff;"><span style="color: #800000;">form </span><span style="color: #ff0000;">role</span><span style="color: #0000ff;">="form"</span><span style="color: #0000ff;">></span>
<span style="color: #008080;"> 2</span>     <span style="color: #0000ff;"><span style="color: #800000;">fieldset </span><span style="color: #ff0000;">disabled</span><span style="color: #0000ff;">></span>
<span style="color: #008080;"> 3</span>         <span style="color: #0000ff;"><span style="color: #800000;">div </span><span style="color: #ff0000;">class</span><span style="color: #0000ff;">="form-group"</span><span style="color: #0000ff;">></span>
<span style="color: #008080;"> 4</span>             <span style="color: #0000ff;"><span style="color: #800000;">label </span><span style="color: #ff0000;">for</span><span style="color: #0000ff;">="disabledTextInput"</span><span style="color: #0000ff;">></span>禁用的输入框<span style="color: #0000ff;"></span><span style="color: #800000;">label</span><span style="color: #0000ff;">></span>
<span style="color: #008080;"> 5</span>             <span style="color: #0000ff;"><span style="color: #800000;">input </span><span style="color: #ff0000;">type</span><span style="color: #0000ff;">="text"</span><span style="color: #ff0000;"> id</span><span style="color: #0000ff;">="disabledTextInput"</span><span style="color: #ff0000;"> class</span><span style="color: #0000ff;">="form-control"</span><span style="color: #ff0000;"> placeholder</span><span style="color: #0000ff;">="禁止输入"</span><span style="color: #0000ff;">></span>
<span style="color: #008080;"> 6</span>         <span style="color: #0000ff;"></span><span style="color: #800000;">div</span><span style="color: #0000ff;">></span>
<span style="color: #008080;"> 7</span>         <span style="color: #0000ff;"><span style="color: #800000;">div </span><span style="color: #ff0000;">class</span><span style="color: #0000ff;">="form-group"</span><span style="color: #0000ff;">></span>
<span style="color: #008080;"> 8</span>             <span style="color: #0000ff;"><span style="color: #800000;">label </span><span style="color: #ff0000;">for</span><span style="color: #0000ff;">="disabledSelect"</span><span style="color: #0000ff;">></span>禁用的下拉框<span style="color: #0000ff;"></span><span style="color: #800000;">label</span><span style="color: #0000ff;">></span>
<span style="color: #008080;"> 9</span>             <span style="color: #0000ff;"><span style="color: #800000;">select </span><span style="color: #ff0000;">id</span><span style="color: #0000ff;">="disabledSelect"</span><span style="color: #ff0000;"> class</span><span style="color: #0000ff;">="form-control"</span><span style="color: #0000ff;">></span>
<span style="color: #008080;">10</span>                 <span style="color: #0000ff;"><span style="color: #800000;">option</span><span style="color: #0000ff;">></span>不可选择<span style="color: #0000ff;"></span><span style="color: #800000;">option</span><span style="color: #0000ff;">></span>
<span style="color: #008080;">11</span>             <span style="color: #0000ff;"></span><span style="color: #800000;">select</span><span style="color: #0000ff;">></span>
<span style="color: #008080;">12</span>         <span style="color: #0000ff;"></span><span style="color: #800000;">div</span><span style="color: #0000ff;">></span>
<span style="color: #008080;">13</span>         <span style="color: #0000ff;"><span style="color: #800000;">div </span><span style="color: #ff0000;">class</span><span style="color: #0000ff;">="checkbox"</span><span style="color: #0000ff;">></span>
<span style="color: #008080;">14</span>             <span style="color: #0000ff;"><span style="color: #800000;">label</span><span style="color: #0000ff;">></span>
<span style="color: #008080;">15</span>                 <span style="color: #0000ff;"><span style="color: #800000;">input </span><span style="color: #ff0000;">type</span><span style="color: #0000ff;">="checkbox"</span><span style="color: #0000ff;">></span><span style="color: #000000;">无法选择
</span><span style="color: #008080;">16</span>             <span style="color: #0000ff;"></span><span style="color: #800000;">label</span><span style="color: #0000ff;">></span>
<span style="color: #008080;">17</span>         <span style="color: #0000ff;"></span><span style="color: #800000;">div</span><span style="color: #0000ff;">></span>
<span style="color: #008080;">18</span>         <span style="color: #0000ff;"><span style="color: #800000;">button </span><span style="color: #ff0000;">type</span><span style="color: #0000ff;">="submit"</span><span style="color: #ff0000;"> class</span><span style="color: #0000ff;">="btnbtn-primary"</span><span style="color: #0000ff;">></span>提交<span style="color: #0000ff;"></span><span style="color: #800000;">button</span><span style="color: #0000ff;">></span>
<span style="color: #008080;">19</span>     <span style="color: #0000ff;"></span><span style="color: #800000;">fieldset</span><span style="color: #0000ff;">></span>
<span style="color: #008080;">20</span> <span style="color: #0000ff;"></span><span style="color: #800000;">form</span><span style="color: #0000ff;">></span></span></span></span></span></span></span></span></span></span></span></span></span></span>
Copy after login
<span style="font-size: 15px;">效果如下图所示:</span>
Copy after login

<span style="color: #14191e; font-family: Monaco, Menlo, 'Ubuntu Mono', Consolas, source-code-pro, monospace; font-size: 15px;">PS:对于一个禁用的域,若legend中有输入框,则此输入框是无法被禁用的。</span>
Copy after login
<span style="color: #14191e; font-family: Monaco, Menlo, 'Ubuntu Mono', Consolas, source-code-pro, monospace; font-size: 15px;">eg:</span>
Copy after login
<span style="color: #008080;"> 1</span> <span style="color: #0000ff;"><span style="color: #800000;">form </span><span style="color: #ff0000;">role</span><span style="color: #0000ff;">="form"</span><span style="color: #0000ff;">></span>
<span style="color: #008080;"> 2</span>     <span style="color: #0000ff;"><span style="color: #800000;">fieldset </span><span style="color: #ff0000;">disabled</span><span style="color: #0000ff;">></span>
<span style="color: #008080;"> 3</span>         <span style="color: #0000ff;"><span style="color: #800000;">legend</span><span style="color: #0000ff;">><span style="color: #800000;">input </span><span style="color: #ff0000;">type</span><span style="color: #0000ff;">="text"</span><span style="color: #ff0000;"> class</span><span style="color: #0000ff;">="form-control"</span><span style="color: #ff0000;"> placeholder</span><span style="color: #0000ff;">="我没被禁用"</span> <span style="color: #0000ff;">/></span><span style="color: #800000;">legend</span><span style="color: #0000ff;">></span>
<span style="color: #008080;"> 4</span>         <span style="color: #0000ff;"><span style="color: #800000;">div </span><span style="color: #ff0000;">class</span><span style="color: #0000ff;">="form-group"</span><span style="color: #0000ff;">></span>
<span style="color: #008080;"> 5</span>             <span style="color: #0000ff;"><span style="color: #800000;">label </span><span style="color: #ff0000;">for</span><span style="color: #0000ff;">="disabledTextInput"</span><span style="color: #0000ff;">></span>禁用的输入框<span style="color: #0000ff;"></span><span style="color: #800000;">label</span><span style="color: #0000ff;">></span>
<span style="color: #008080;"> 6</span>             <span style="color: #0000ff;"><span style="color: #800000;">input </span><span style="color: #ff0000;">type</span><span style="color: #0000ff;">="text"</span><span style="color: #ff0000;"> id</span><span style="color: #0000ff;">="disabledTextInput"</span><span style="color: #ff0000;"> class</span><span style="color: #0000ff;">="form-control"</span><span style="color: #ff0000;"> placeholder</span><span style="color: #0000ff;">="禁止输入"</span><span style="color: #0000ff;">></span>
<span style="color: #008080;"> 7</span>         <span style="color: #0000ff;"></span><span style="color: #800000;">div</span><span style="color: #0000ff;">></span>
<span style="color: #008080;"> 8</span>         <span style="color: #0000ff;"><span style="color: #800000;">div </span><span style="color: #ff0000;">class</span><span style="color: #0000ff;">="form-group"</span><span style="color: #0000ff;">></span>
<span style="color: #008080;"> 9</span>             <span style="color: #0000ff;"><span style="color: #800000;">label </span><span style="color: #ff0000;">for</span><span style="color: #0000ff;">="disabledSelect"</span><span style="color: #0000ff;">></span>禁用的下拉框<span style="color: #0000ff;"></span><span style="color: #800000;">label</span><span style="color: #0000ff;">></span>
<span style="color: #008080;">10</span>             <span style="color: #0000ff;"><span style="color: #800000;">select </span><span style="color: #ff0000;">id</span><span style="color: #0000ff;">="disabledSelect"</span><span style="color: #ff0000;"> class</span><span style="color: #0000ff;">="form-control"</span><span style="color: #0000ff;">></span>
<span style="color: #008080;">11</span>                 <span style="color: #0000ff;"><span style="color: #800000;">option</span><span style="color: #0000ff;">></span>不可选择<span style="color: #0000ff;"></span><span style="color: #800000;">option</span><span style="color: #0000ff;">></span>
<span style="color: #008080;">12</span>             <span style="color: #0000ff;"></span><span style="color: #800000;">select</span><span style="color: #0000ff;">></span>
<span style="color: #008080;">13</span>         <span style="color: #0000ff;"></span><span style="color: #800000;">div</span><span style="color: #0000ff;">></span>
<span style="color: #008080;">14</span>         <span style="color: #0000ff;"><span style="color: #800000;">div </span><span style="color: #ff0000;">class</span><span style="color: #0000ff;">="checkbox"</span><span style="color: #0000ff;">></span>
<span style="color: #008080;">15</span>             <span style="color: #0000ff;"><span style="color: #800000;">label</span><span style="color: #0000ff;">></span>
<span style="color: #008080;">16</span>                 <span style="color: #0000ff;"><span style="color: #800000;">input </span><span style="color: #ff0000;">type</span><span style="color: #0000ff;">="checkbox"</span><span style="color: #0000ff;">></span><span style="color: #000000;">无法选择
</span><span style="color: #008080;">17</span>             <span style="color: #0000ff;"></span><span style="color: #800000;">label</span><span style="color: #0000ff;">></span>
<span style="color: #008080;">18</span>         <span style="color: #0000ff;"></span><span style="color: #800000;">div</span><span style="color: #0000ff;">></span>
<span style="color: #008080;">19</span>         <span style="color: #0000ff;"><span style="color: #800000;">button </span><span style="color: #ff0000;">type</span><span style="color: #0000ff;">="submit"</span><span style="color: #ff0000;"> class</span><span style="color: #0000ff;">="btnbtn-primary"</span><span style="color: #0000ff;">></span>提交<span style="color: #0000ff;"></span><span style="color: #800000;">button</span><span style="color: #0000ff;">></span>
<span style="color: #008080;">20</span>   <span style="color: #0000ff;"></span><span style="color: #800000;">fieldset</span><span style="color: #0000ff;">></span> 
<span style="color: #008080;">21</span> <span style="color: #0000ff;"></span><span style="color: #800000;">form</span><span style="color: #0000ff;">></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span>
Copy after login
<span style="font-size: 15px;">效果图如下所示:</span>
Copy after login
Copy after login

<span style="font-size: 15px;"><strong>三、验证状态:</strong>该状态告诉用户,他们的操作是否正确</span>
Copy after login
在Bootstrap中提供3种验证状态样式:
① .has-success : 成功状态(绿色)
② .has-error : 错误状态(红色)
③ .has-warning : 警告状态(黄色)
使用方法:在form-group容器上添加对应的状态类名即可。
<span style="font-size: 15px;">eg:</span>
<span style="color: #008080;"> 1</span> <span style="color: #0000ff;"><span style="color: #800000;">form </span><span style="color: #ff0000;">role</span><span style="color: #0000ff;">="form"</span><span style="color: #0000ff;">></span>
<span style="color: #008080;"> 2</span>     <span style="color: #0000ff;"><span style="color: #800000;">div </span><span style="color: #ff0000;">class</span><span style="color: #0000ff;">="form-group has-success"</span><span style="color: #0000ff;">></span>
<span style="color: #008080;"> 3</span>         <span style="color: #0000ff;"><span style="color: #800000;">label </span><span style="color: #ff0000;">class</span><span style="color: #0000ff;">="control-label"</span><span style="color: #ff0000;"> for</span><span style="color: #0000ff;">="inputSuccess1"</span><span style="color: #0000ff;">></span>成功状态<span style="color: #0000ff;"></span><span style="color: #800000;">label</span><span style="color: #0000ff;">></span>
<span style="color: #008080;"> 4</span>         <span style="color: #0000ff;"><span style="color: #800000;">input </span><span style="color: #ff0000;">type</span><span style="color: #0000ff;">="text"</span><span style="color: #ff0000;"> class</span><span style="color: #0000ff;">="form-control"</span><span style="color: #ff0000;"> id</span><span style="color: #0000ff;">="inputSuccess1"</span><span style="color: #ff0000;"> placeholder</span><span style="color: #0000ff;">="成功状态"</span> <span style="color: #0000ff;">></span>
<span style="color: #008080;"> 5</span>     <span style="color: #0000ff;"></span><span style="color: #800000;">div</span><span style="color: #0000ff;">></span>
<span style="color: #008080;"> 6</span>     <span style="color: #0000ff;"><span style="color: #800000;">div </span><span style="color: #ff0000;">class</span><span style="color: #0000ff;">="form-group has-warning"</span><span style="color: #0000ff;">></span>
<span style="color: #008080;"> 7</span>         <span style="color: #0000ff;"><span style="color: #800000;">label </span><span style="color: #ff0000;">class</span><span style="color: #0000ff;">="control-label"</span><span style="color: #ff0000;"> for</span><span style="color: #0000ff;">="inputWarning1"</span><span style="color: #0000ff;">></span>警告状态<span style="color: #0000ff;"></span><span style="color: #800000;">label</span><span style="color: #0000ff;">></span>
<span style="color: #008080;"> 8</span>         <span style="color: #0000ff;"><span style="color: #800000;">input </span><span style="color: #ff0000;">type</span><span style="color: #0000ff;">="text"</span><span style="color: #ff0000;"> class</span><span style="color: #0000ff;">="form-control"</span><span style="color: #ff0000;"> id</span><span style="color: #0000ff;">="inputWarning1"</span><span style="color: #ff0000;"> placeholder</span><span style="color: #0000ff;">="警告状态"</span><span style="color: #0000ff;">></span>
<span style="color: #008080;"> 9</span>     <span style="color: #0000ff;"></span><span style="color: #800000;">div</span><span style="color: #0000ff;">></span>
<span style="color: #008080;">10</span>     <span style="color: #0000ff;"><span style="color: #800000;">div </span><span style="color: #ff0000;">class</span><span style="color: #0000ff;">="form-group has-error"</span><span style="color: #0000ff;">></span>
<span style="color: #008080;">11</span>         <span style="color: #0000ff;"><span style="color: #800000;">label </span><span style="color: #ff0000;">class</span><span style="color: #0000ff;">="control-label"</span><span style="color: #ff0000;"> for</span><span style="color: #0000ff;">="inputError1"</span><span style="color: #0000ff;">></span>错误状态<span style="color: #0000ff;"></span><span style="color: #800000;">label</span><span style="color: #0000ff;">></span>
<span style="color: #008080;">12</span>         <span style="color: #0000ff;"><span style="color: #800000;">input </span><span style="color: #ff0000;">type</span><span style="color: #0000ff;">="text"</span><span style="color: #ff0000;"> class</span><span style="color: #0000ff;">="form-control"</span><span style="color: #ff0000;"> id</span><span style="color: #0000ff;">="inputError1"</span><span style="color: #ff0000;"> placeholder</span><span style="color: #0000ff;">="错误状态"</span><span style="color: #0000ff;">></span>
<span style="color: #008080;">13</span>     <span style="color: #0000ff;"></span><span style="color: #800000;">div</span><span style="color: #0000ff;">></span>
<span style="color: #008080;">14</span> <span style="color: #0000ff;"></span><span style="color: #800000;">form</span><span style="color: #0000ff;">></span></span></span></span></span></span></span></span></span></span></span>
Copy after login
<span style="font-size: 15px;">说明:从效果可看出,三种样式除了颜色不同外,效果都一样。</span>
Copy after login
<span style="font-size: 15px;">在Bootstrap的表单验证中,不同状态会提供不同的icon,如成功是个对号"√",错误是个叉号"×"等。</span>
Copy after login
<span style="font-size: 15px;">若想让表单在不同状态下显示对应的icon,则只需在对应状态下添加类名"has-feedback"。</span>
Copy after login
<span style="font-size: 15px;">PS:类名"has-feedback"要与"has-error"、"has-warning"、"has-success"配合使用。</span>
Copy after login
<span style="font-size: 15px;">eg:</span>
Copy after login
Copy after login
Copy after login
Copy after login
<span style="color: #008080;"> 1</span> <span style="color: #0000ff;"><span style="color: #800000;">form </span><span style="color: #ff0000;">role</span><span style="color: #0000ff;">="form"</span><span style="color: #0000ff;">></span>
<span style="color: #008080;"> 2</span>     <span style="color: #0000ff;"><span style="color: #800000;">div </span><span style="color: #ff0000;">class</span><span style="color: #0000ff;">="form-group has-success has-feedback"</span><span style="color: #0000ff;">></span>
<span style="color: #008080;"> 3</span>         <span style="color: #0000ff;"><span style="color: #800000;">label </span><span style="color: #ff0000;">class</span><span style="color: #0000ff;">="control-label"</span><span style="color: #ff0000;"> for</span><span style="color: #0000ff;">="inputSuccess"</span><span style="color: #0000ff;">></span>成功状态<span style="color: #0000ff;"></span><span style="color: #800000;">label</span><span style="color: #0000ff;">></span>
<span style="color: #008080;"> 4</span>         <span style="color: #0000ff;"><span style="color: #800000;">input </span><span style="color: #ff0000;">type</span><span style="color: #0000ff;">="text"</span><span style="color: #ff0000;"> class</span><span style="color: #0000ff;">="form-control"</span><span style="color: #ff0000;"> id</span><span style="color: #0000ff;">="inputSuccess"</span><span style="color: #ff0000;"> placeholder</span><span style="color: #0000ff;">="成功状态"</span> <span style="color: #0000ff;">></span>
<span style="color: #008080;"> 5</span>         <span style="color: #0000ff;"><span style="color: #800000;">span </span><span style="color: #ff0000;">class</span><span style="color: #0000ff;">="glyphicon glyphicon-ok form-control-feedback"</span><span style="color: #0000ff;">></span><span style="color: #800000;">span</span><span style="color: #0000ff;">></span>
<span style="color: #008080;"> 6</span>     <span style="color: #0000ff;"></span><span style="color: #800000;">div</span><span style="color: #0000ff;">></span>
<span style="color: #008080;"> 7</span>     <span style="color: #0000ff;"><span style="color: #800000;">div </span><span style="color: #ff0000;">class</span><span style="color: #0000ff;">="form-group has-warning has-feedback"</span><span style="color: #0000ff;">></span>
<span style="color: #008080;"> 8</span>         <span style="color: #0000ff;"><span style="color: #800000;">label </span><span style="color: #ff0000;">class</span><span style="color: #0000ff;">="control-label"</span><span style="color: #ff0000;"> for</span><span style="color: #0000ff;">="inputWarning"</span><span style="color: #0000ff;">></span>警告状态<span style="color: #0000ff;"></span><span style="color: #800000;">label</span><span style="color: #0000ff;">></span>
<span style="color: #008080;"> 9</span>         <span style="color: #0000ff;"><span style="color: #800000;">input </span><span style="color: #ff0000;">type</span><span style="color: #0000ff;">="text"</span><span style="color: #ff0000;"> class</span><span style="color: #0000ff;">="form-control"</span><span style="color: #ff0000;"> id</span><span style="color: #0000ff;">="inputWarning"</span><span style="color: #ff0000;"> placeholder</span><span style="color: #0000ff;">="警告状态"</span> <span style="color: #0000ff;">></span>
<span style="color: #008080;">10</span>         <span style="color: #0000ff;"><span style="color: #800000;">span </span><span style="color: #ff0000;">class</span><span style="color: #0000ff;">="glyphicon glyphicon-warning-sign form-control-feedback"</span><span style="color: #0000ff;">></span><span style="color: #800000;">span</span><span style="color: #0000ff;">></span>
<span style="color: #008080;">11</span>   <span style="color: #0000ff;"></span><span style="color: #800000;">div</span><span style="color: #0000ff;">></span> 
<span style="color: #008080;">12</span>   <span style="color: #0000ff;"><span style="color: #800000;">div </span><span style="color: #ff0000;">class</span><span style="color: #0000ff;">="form-group has-error has-feedback"</span><span style="color: #0000ff;">></span>
<span style="color: #008080;">13</span>         <span style="color: #0000ff;"><span style="color: #800000;">label </span><span style="color: #ff0000;">class</span><span style="color: #0000ff;">="control-label"</span><span style="color: #ff0000;"> for</span><span style="color: #0000ff;">="inputError"</span><span style="color: #0000ff;">></span>错误状态<span style="color: #0000ff;"></span><span style="color: #800000;">label</span><span style="color: #0000ff;">></span>
<span style="color: #008080;">14</span>         <span style="color: #0000ff;"><span style="color: #800000;">input </span><span style="color: #ff0000;">type</span><span style="color: #0000ff;">="text"</span><span style="color: #ff0000;"> class</span><span style="color: #0000ff;">="form-control"</span><span style="color: #ff0000;"> id</span><span style="color: #0000ff;">="inputError"</span><span style="color: #ff0000;"> placeholder</span><span style="color: #0000ff;">="错误状态"</span> <span style="color: #0000ff;">></span>
<span style="color: #008080;">15</span>         <span style="color: #0000ff;"><span style="color: #800000;">span </span><span style="color: #ff0000;">class</span><span style="color: #0000ff;">="glyphicon glyphicon-remove form-control-feedback"</span><span style="color: #0000ff;">></span><span style="color: #800000;">span</span><span style="color: #0000ff;">></span>
<span style="color: #008080;">16</span>   <span style="color: #0000ff;"></span><span style="color: #800000;">div</span><span style="color: #0000ff;">></span> 
<span style="color: #008080;">17</span> <span style="color: #0000ff;"></span><span style="color: #800000;">form</span><span style="color: #0000ff;">></span></span></span></span></span></span></span></span></span></span></span></span></span></span>
Copy after login
<span style="font-size: 15px;">效果如下所示:</span>
Copy after login
<span style="font-size: 15px;">说明:从效果图中可看出,图标都居右。</span>
Copy after login
<span style="font-size: 15px;">注:Bootstrap中的图标都是使用@face-face来制作,且必须在表单中添加个span元素来实现。</span>
Copy after login
<span style="font-size: 15px;">eg:</span>
Copy after login
Copy after login
Copy after login
Copy after login
<span style="color: #0000ff;"><span style="color: #800000;">span </span><span style="color: #ff0000;">class</span><span style="color: #0000ff;">="glyphicon glyphicon-remove form-control-feedback"</span><span style="color: #0000ff;">></span><span style="color: #800000;">span</span><span style="color: #0000ff;">></span></span>
Copy after login
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template