當前位置: 首頁>>編程示例 >>用法及示例精選 >>正文


HTML step屬性用法及代碼示例

HTML中的step屬性用於設置<input>元素的離散步長。數字輸入的默認步進值為1。

用法:它適用於以下輸入類型:數字,範圍,日期,日期時間,月份,時間。

用法:

<input step = "value">

例:

<!DOCTYPE html> 
<html> 
  
<head> 
    <title>HTML step Attribute</title> 
    <style> 
        h1, 
        h2 { 
            text-align:center; 
        } 
    </style> 
</head> 
  
<body> 
    <center> 
        <h1 style="color:green;"> 
            GeeksforGeeks 
        </h1> 
  
        <h2> 
            HTML step Attribute 
        </h2> 
  
        <input type="number" name="points" step="5" 
                       placeholder="multiples of 5"> 
    </center> 
</body> 
  
</html>

輸出:
step

支持的瀏覽器:下麵列出了step屬性支持的瀏覽器:

  • 穀歌瀏覽器6.0
  • Internet Explorer 10.0
  • Firefox 16.0
  • Opera 10.6
  • Safari 5.0

相關用法


注:本文由純淨天空篩選整理自Vishal Chaudhary 2大神的英文原創作品 HTML | step Attribute。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。