Bootstrap- vorm-insette (meer)


Statiese beheer

As jy gewone teks langs 'n vormetiket binne 'n horisontale vorm moet invoeg, gebruik die .form-control-staticklas op 'n <p>element:

Voorbeeld

<form class="form-horizontal">
  <div class="form-group">
    <label class="control-label col-sm-2">Email:</label>
    <div class="col-sm-10">
      <p class="form-control-static">[email protected]</p>
    </div>
  </div>
</form>

Bootstrap-invoergroepe

Die .input-groupklas is 'n houer om 'n inset te verbeter deur 'n ikoon, teks of 'n knoppie voor of agter dit by te voeg as 'n "hulpteks".

Die .input-group-addonklas heg 'n ikoon of hulpteks langs die invoerveld aan.


Teks

Voorbeeld

<form>
  <div class="input-group">
    <span class="input-group-addon"><i class="glyphicon glyphicon-user"></i></span>
    <input id="email" type="text" class="form-control" name="email" placeholder="Email">
  </div>
  <div class="input-group">
    <span class="input-group-addon"><i class="glyphicon glyphicon-lock"></i></span>
    <input id="password" type="password" class="form-control" name="password" placeholder="Password">
  </div>
  <div class="input-group">
    <span class="input-group-addon">Text</span>
    <input id="msg" type="text" class="form-control" name="msg" placeholder="Additional Info">
  </div>
</form>

Die .input-group-btnheg 'n knoppie langs 'n invoer. Dit word dikwels saam met 'n soekbalk gebruik:

Voorbeeld

<form>
  <div class="input-group">
    <input type="text" class="form-control" placeholder="Search">
    <div class="input-group-btn">
      <button class="btn btn-default" type="submit">
        <i class="glyphicon glyphicon-search"></i>
      </button>
    </div>
  </div>
</form>


Bootstrap Form Control State

  • INSETFOKUS - Die buitelyn van die invoer word verwyder en 'n boksskadu word op fokus toegepas
  • GEDEAKTIVEERDE INSETTE - Voeg 'n disabledkenmerk by om 'n invoerveld te deaktiveer
  • GEDEAKTIVEERDE VELDSTELLE - Voeg 'n disabledkenmerk by 'n veldstel om alle kontroles binne te deaktiveer
  • LEESALLEEN INSETTE - Voeg 'n readonlykenmerk by 'n invoer om gebruikersinvoer te voorkom
  • VALIDERINGSTATE - Bootstrap bevat valideringstyle vir fout-, waarskuwings- en suksesboodskappe. Om te gebruik, voeg .has-warning, .has-error, of .has-successby die ouerelement
  • IKONE - Jy kan terugvoer-ikone by die .has-feedbackklas en 'n ikoon byvoeg
  • VERBORGDE ETIKETTE - Voeg 'n .sr-onlyklas oor nie-sigbare etikette by

Die volgende voorbeeld demonstreer sommige van die vormbeheertoestande hierbo in 'n horisontale vorm :

Voorbeeld

<form class="form-horizontal">
  <div class="form-group">
    <label class="col-sm-2 control-label">Focused</label>
    <div class="col-sm-10">
      <input class="form-control" id="focusedInput" type="text" value="Click to focus">
    </div>
  </div>
  <div class="form-group">
    <label for="disabledInput" class="col-sm-2 control-label">Disabled</label>
    <div class="col-sm-10">
      <input class="form-control" id="disabledInput" type="text" disabled>
    </div>
  </div>
  <fieldset disabled>
    <div class="form-group">
      <label for="disabledTextInput" class="col-sm-2 control-label">Fieldset disabled</label>
      <div class="col-sm-10">
        <input type="text" id="disabledTextInput" class="form-control">
      </div>
    </div>
    <div class="form-group">
      <label for="disabledSelect" class="col-sm-2 control-label"></label>
      <div class="col-sm-10">
        <select id="disabledSelect" class="form-control">
          <option>Disabled select</option>
        </select>
      </div>
    </div>
  </fieldset>
  <div class="form-group has-success has-feedback">
    <label class="col-sm-2 control-label" for="inputSuccess">
    Input with success and icon</label>
    <div class="col-sm-10">
      <input type="text" class="form-control" id="inputSuccess">
      <span class="glyphicon glyphicon-ok form-control-feedback"></span>
    </div>
  </div>
  <div class="form-group has-warning has-feedback">
    <label class="col-sm-2 control-label" for="inputWarning">
    Input with warning and icon</label>
    <div class="col-sm-10">
      <input type="text" class="form-control" id="inputWarning">
      <span class="glyphicon glyphicon-warning-sign form-control-feedback"></span>
    </div>
  </div>
  <div class="form-group has-error has-feedback">
    <label class="col-sm-2 control-label" for="inputError">
    Input with error and icon</label>
    <div class="col-sm-10">
      <input type="text" class="form-control" id="inputError">
      <span class="glyphicon glyphicon-remove form-control-feedback"></span>
    </div>
  </div>
</form>

En hier is 'n voorbeeld van sommige van die vormbeheertoestande in 'n inlynvorm :

Voorbeeld

<form class="form-inline">
  <div class="form-group">
    <label for="focusedInput">Focused</label>
    <input class="form-control" id="focusedInput" type="text">
  </div>
  <div class="form-group">
    <label for="inputPassword">Disabled</label>
    <input class="form-control" id="disabledInput" type="text" disabled>
  </div>
  <div class="form-group has-success has-feedback">
    <label for="inputSuccess2">Input with success</label>
    <input type="text" class="form-control" id="inputSuccess2">
    <span class="glyphicon glyphicon-ok form-control-feedback"></span>
  </div>
  <div class="form-group has-warning has-feedback">
    <label for="inputWarning2">Input with warning</label>
    <input type="text" class="form-control" id="inputWarning2">
    <span class="glyphicon glyphicon-warning-sign form-control-feedback"></span>
  </div>
  <div class="form-group has-error has-feedback">
    <label for="inputError2">Input with error</label>
    <input type="text" class="form-control" id="inputError2">
    <span class="glyphicon glyphicon-remove form-control-feedback"></span>
  </div>
</form>