类型为number的input框如何输入小数

当text="number"时,input框有个设置步长的属性step,通过设置这个属性,我们可以让input框支持小数,同时,还能限定小数的长度

示例

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html >
  <head>
    <title></title>

    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
    <link rel="stylesheet" href="bootstrap.min.css" />    
  </head>  
<body >       
<div class="input-group" style="width:240px;">                                                
    <input type="number" class="form-control" step="0.1" style="width:240px;margin-right:0px">                                            
                                        
</div>

</body>
  
</html>

这里我步长设为0.1,就是长度是一位小数

效果

猜你喜欢

转载自blog.csdn.net/qq_33543634/article/details/82424881