Bootstrap输入表单控件无法在移动设备上运行

时间:2017-09-30 23:18:08

标签: html twitter-bootstrap

我在移动版中输入的不是打开键盘来输入数据。当我点击输入时没有任何反应(在移动设备中)。此问题仅发生在移动设备中。

<!DOCTYPE html>
    <html lang="en">
    	
    <head>
    
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1.0" />
        <meta name="description" content="">
        <meta name="author" content="">
    	
    	<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
    	<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>
    	<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css">
    </head>
    	
    <body>
    	<div class="container">
    		<div class="row">
    			<div class="col-md-4">
    				<div class="panel panel-info">
    					<div class="panel-heading">
    						<h3 class="panel-title" align="center" style="display: inline;font-weight: bold;">Credit Card</h3>
    					</div>
    					<div class="panel-body">
    						<form role="form">
    						<div class='form-row'>
    							<div class="col-xs-12 form-group">
    								<label class='control-label'>Name on Card</label>
    								<input class="form-control" id="nameOnCard" type="text" value="">
    							</div>
    							<div class="col-xs-12 form-group">
    								<label class='control-label'>Card Number</label>
    								<input class="form-control" id="cardNumber" size="20" type='text' value="">
    							</div>
    							<div class="col-xs-6 form-group">
    								<label class='control-label'>Zip Code</label>
    								<input class="form-control" id="zipCode" size="6" type='text' value="">
    							</div>
    						</div>
    						<div class='form-row'>
    							  <div class='col-xs-4 form-group cvc required'>
    								<label class='control-label'>CVC</label>
    								<input id="CardCVC" class='form-control' placeholder='ex. 311' size='4' type='text' value="">
    							  </div>
    							  <div class='col-xs-4 form-group expiration required'>
    								<label class='control-label'>Expiration</label>
    								<input class='form-control' id="expMonth" placeholder='MM' size='2' type='text' value="">
    							  </div>
    							  <div class='col-xs-4 form-group expiration required'>
    								<label class='control-label'> </label>
    								<input class='form-control' id="expYear" placeholder='YY' size='2' type='text' value="">
    							  </div>
    						</div>
    						<div class='form-row'>
    						  <div class='col-md-12 form-group'>
    							<button class='form-control btn btn-primary' type='button' onClick="updateCreditCard();">Update</button>
    						  </div>
    						</div>
    						</form>
    					</div>
    				</div>
    			</div>
    		</div>
    	</div>
    </body>
    
    </html>

有谁知道为什么会这样?调试控制台中没有错误。当我使用我的电脑尝试时,代码工作正常。

由于

1 个答案:

答案 0 :(得分:2)

你没有以正确的方式使用form group

我已修好

我刚刚为此输入表单更改了form-group

<div class='form-row'>
         <div class="col-xs-12 form-group">
            <label class='control-label'>Name on Card</label>
            <input class="form-control" id="nameOnCard" type="text" value="">
         </div>
         <div class="col-xs-12 form-group">
            <label class='control-label'>Card Number</label>
            <input class="form-control" id="cardNumber" size="20" type='text' value="">
         </div>
         <div class="col-xs-6 form-group">
            <label class='control-label'>Zip Code</label>
            <input class="form-control" id="zipCode" size="6" type='text' value=""> 
        </div>
</div>

是这样的:

<div class="form-group col-md-12">                                
        <label class='control-label'>Name on Card</label>
        <input class="form-control" id="nameOnCard" type="text" value="">          
 </div>
 <div class="form-group col-md-12">                       
        <label class='control-label'>Card Number</label>
        <input class="form-control" id="cardNumber" size="20" type='text' value="">
 </div>
 <div class="form-group col-md-12">                           
        <label class='col-md-12 control-label'>Zip Code</label>
        <input class="form-control" id="zipCode" size="6" type='text' value="">
  </div>

每个输入的form-group都是正确的,但最重要的是,form-row没有必要像提问者那样制作。

&#13;
&#13;
<!DOCTYPE html>
<htm>
        <head>
        
            <meta charset="utf-8">
            <meta http-equiv="X-UA-Compatible" content="IE=edge">
            <meta name="viewport" content="width=device-width, initial-scale=1.0" />
            <meta name="description" content="">
            <meta name="author" content="">
        	
        	
        	<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css">
        </head>
        	
        <body>
        	<div class="container">
        		<div class="row">
        			<div class="col-md-6">
        				<div class="panel panel-info">
        					<div class="panel-heading">
        						<h3 class="panel-title" align="center" style="display: inline;font-weight: bold;">Credit Card</h3>
        					</div>
        					<div class="panel-body">
        						<form >
        						
        							<div class="form-group col-md-12">
                            
        								<label class='control-label'>Name on Card</label>
        								<input class="form-control" id="nameOnCard" type="text" value="">
                    
        							</div>
        							<div class="form-group col-md-12 col-xs-12">
                                 
        								<label class='control-label'>Card Number</label>
        								<input class="form-control" id="cardNumber" size="20" type='text' value="">
        							</div>
        							<div class="form-group col-md-6 col-xs-12">
        								<label class='control-label'>Zip Code</label>
        								<input class="form-control" id="zipCode" size="6" type='text' value="">
                                       
                                    </div>
                                    <div class="form-group col-md-6 col-xs-12">
                                        <label class='control-label'>CVC</label>
                                        <input id="CardCVC" class='form-control' placeholder='ex. 311' size='4' type='text' value="">
                                    </div>
        							  <div class='form-group col-md-4 col-xs-12 expiration required'>
        								<label class='control-label'>Expiration</label>
        								<input class='form-control' id="expMonth" placeholder='MM' size='2' type='text' value="">
        							  </div>
        							  <div class=' form-group col-md-6 col-xs-12  expiration required'>
        								<label class='control-label'> </label>
        								<input class='form-control' id="expYear" placeholder='YY' size='2' type='text' value="">
        							  </div>
                                    <div class="form-group">
    							<button class="btn btn-primary col-md-12 col-xs-12" onClick="updateCreditCard();">Update</button>
                    
                            </div>
        						</form>
        					</div>
        				</div>
        			</div>
        		</div>
        	</div>
        </body>
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
            <script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>
        </html>
&#13;
&#13;
&#13;

查看此网站如何使用form group