laravel Twitter Bootstrap 3 输入和图标不显示内联

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/20384042/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 08:44:01  来源:igfitidea点击:

Twitter Bootstrap 3 Input and icon do not display inline

csstwitter-bootstraplaravellaravel-4twitter-bootstrap-3

提问by John

My problem is that I cannot display my glyphicon before my inputs.

我的问题是我无法在输入之前显示我的字形。

problem

问题

Here is my code:

这是我的代码:

<div class="modal fade " id="login" tabindex="-1" role="dialog" aria-    labelledby="myModalLabel" aria-hidden="true">      
 <div class="modal-dialog">

<div class="modal-content">

  <div class="modal-header text-center">

    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;    </button>
    <h4 class="modal-title">Log in</h4>
  </div>{{--close modal header --}}



  <div class="modal-body text-center">

    {{ Form::open(array('url'=>'/' ,'role'=>'form')) }}


   @if($errors->count()>0)
      <div class="alert alert-danger" style="text-align:center;">

        <p>Errors</p>

        <ul>
          @foreach($errors->all() as $error)
            <li>
              {{$error}}
            </li>
          @endforeach
        </ul>
      </div>
    @endif


    @if(Session::has('flash_message'))
      <div class="alert alert-danger" style="text-align:center;">
      <p>{{Session::get('flash_message')}}</p>

      </div>
    @endif


    <div class="form-group">

      <span class="glyphicon  glyphicon-user ">   
        {{ Form::text('username', null, ['required'=>'1','placeholder'=>'Username','id'=>'user','class'=>'form-control']) }}
        </span>

      </div>


      <div class="form-group">

        <span class="glyphicon  glyphicon-lock "> 

          {{ Form::password('password',      ['required'=>'1','placeholder'=>'Password','id'=>'password','class'=>'form-control']) }}
        </span>
      </div>

           <br/>

       {{'          &nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;   
       '}}


       {{ Form::submit('login',['class'=>'btn']) }} 

       or

       {{ Form::button('Sign up',['class'=>'btn btn-danger','data-dismiss'=>'modal','data-toggle'=>'modal','data-target'=>'#signup']) 
        }}



      {{ Form::close() }}



  </div>{{--close modal body --}}





  <div class="modal-footer">
    <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>

  </div>

</div><!-- /.modal-content -->

  </div><!-- /.modal-dialog -->


</div> {{--close modal --}}

Where rows such as {{ Form::text('username', null, ['required'=>'1','placeholder'=>'Username','id'=>'user','class'=>'form-control']) }} are Laravel 4 commands which generate input type="text" name="text" class="form-control pleceholder= ...

其中行如 {{ Form::text('username', null, ['required'=>'1','placeholder'=>'Username','id'=>'user','class'=> 'form-control']) }} 是 Laravel 4 命令,它们生成 input type="text" name="text" class="form-control pleceholder= ...

Please answer only for bootstrap 3..

请仅针对引导程序 3 回答..

回答by zessx

You could use .form-horizontal, and put your glyphicon in an other column than the field :

您可以使用.form-horizontal, 并将您的字形放在字段之外的其他列中:

enter image description here

在此处输入图片说明

<form class="form-horizontal" role="form">

    <div class="form-group">
        <label class="col-sm-1 col-sm-offset-3 control-label"><span class="glyphicon glyphicon-user"></span></label>
        <div class="col-sm-5">
            <input type="text" placeholder="Username" class="form-control"/>
        </div>
    </div>

    <div class="form-group">
        <label class="col-sm-1 col-sm-offset-3 control-label"><span class="glyphicon glyphicon-lock"></span></label>
        <div class="col-sm-5">
            <input type="password" placeholder="Username" class="form-control"/>
        </div>
    </div>

    <br/>
    <input type="submit" class="btn btn-default" value="Login"/>
    &nbsp;or&nbsp;
    <input type="submit" class="btn btn-danger" value="Sign up"/>

</form>

Play with col-sm-xand col-sm-offset-xto get the width you need.

col-sm-xcol-sm-offset-x以获得您需要的宽度。

Bootply

引导