jQWidgets jqxFormattedInput 主题属性

  • Post category:jquery

jQWidgets jqxFormattedInput 主题属性

jQWidgets是一个基于jQuery的UI组件库,提供了丰富的UI件和工具,包括表格、图表、日历、菜单等。jqxFormattedInputjQWidgets中的一个组件,可以用于输入和格式化数字、货币、日期等。jqxFormattedInput提供了theme属性,用于设置数字输入框的主题。

theme属性的基本语法

theme属性用于设置数字输入框的主题。其基本语法如下:

$('#jqxFormattedInput').jqxFormattedInput({
  theme: 'classic'
});

jqxFormattedInput组件中,可以通过设置theme属性来设置数字输入框的主题。

示例1:使用内置主题

以下是一个示例,演示如何使用内置主题设置数字输入框的样式:

<!DOCTYPE>
<html>
<head>
  <meta charset="UTF-8">
 <title>jQWidgets FormattedInput Example</title>
  <link rel="stylesheet" href="https://cdn.jqwidgets.com/jquery.jqwidgets/4.5.3/jqwidgets/styles/jqx.base.css">
  <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
  <script src="https://cdn.jqwidgets.com/jquery.jqwidgets/4.5.3/jqwidgets/jqxcore.js"></script>
  <script src="https://cdn.jqwidgets.com/jquery.jqwidgets/4.5.3/jqwidgets/jqxdata.js"></script>
  <script src="https://cdn.jqwidgets.com/jquery.jqwidgets/4.5.3/jqwidgets/jqxbuttons.js"></script>
  <script src="https://cdn.jqwidgets.com/jquery.jqwidgets/4.5.3/jqwidgets/jqxinput.js"></script>
</head>
<body>
  <div id="jqxFormattedInput"></div>
  <script>
    $(document).ready(function () {
      $('#jqxFormattedInput').jqxFormattedInput({
        width: '250px',
        height: '25px',
        theme: 'classic'
      });
    });
  </script>
</body>
</html>

在这个示例中我们使用jqxFormattedInput组件创建了一个数字输入框,并设置了theme属性为classic,以使用内置的classic主题。

示例2:自定义主题

以下是另一个示例,演示何自定义数字输入框的主题:

<!DOCTYPE html>
<html>
<head>
  < charset="UTF-8">
  <title>jQWidgets FormattedInput Example</title>
  <link rel="stylesheet" href="https://cdn.jqwidgets.com/jquery.jqwidgets/4.5.3/jqwidgets/styles/jqx.base.css">
  <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
  <script src="https://cdn.jqwidgets.com/jquery.jqwidgets/4.5.3/jqwidgets/jqxcore.js"></script>
  <script src="https://cdn.jqwidgets.com/jquery.jqwidgets/4.5.3/jqwidgets/jqxdata.js"></script>
  <script src="https://cdn.jqwidgets.com/jquery.jqwidgets/4.5.3/jqwidgets/jqxbuttons.js"></script>
  <script src="https://cdn.jqwidgets.com/jquery.jqwidgets/4.5.3/jqwidgets/jqxformattedinput.js"></script>
  <style>
    .custom-theme .jqx-formatted-input {
      border: 1px solid #ccc;
      background-color: #f5f5f5;
      color: #333;
      font-size: 14px;
      padding: 5px;
    }
    .custom-theme .jqx-formatted-input:focus {
      border-color: #66afe9;
      outline: 0;
      box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 8px rgba(102, 175, , 0.6);
    }
    .custom-theme .jqx-formatted-input::-webkit-input-placeholder {
      color: #999;
    }
    .custom-theme .jqx-formatted-input::-moz-placeholder {
      color: #999;
    }
    .custom-theme .jqx-formatted-input:-ms-input-placeholder {
      color: #999;
    }
    .custom-theme .jqx-formatted-input::-ms-input-placeholder {
      color: #999;
    }
  </style>
</head>
<body>
  <div id="jqxFormattedInput"></div>
  <script>
    $(document).ready(function () {
      $('#jqxFormattedInput').jqxFormattedInput({
        width: '250px',
        height: '25px',
        theme: 'custom-theme'
      });
    });
  </script>
</body>
</html>

在这个示例中,我们使用jqxFormattedInput组件创建了一个数字输入框,并设置了theme属性为custom-theme,以自定义数字输入框的主题。我们还定义了一个名为custom-theme的CSS类,用于设置输入框的样式。

综上所述,jqxFormattedInput提供了theme属性,用于设置数字输入框的主题。本文详细介绍了theme属性的使用和示例。

参考