css美化number类型输入框美化实现自定义+、-号点击按钮增减效果

简介:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<!DOCTYPE html>
<html lang= "en" >
         
<head>
   <meta charset= "utf-8"  />
   <title>Jay Skript And The Domsters</title>
  <style type= "text/css" >
  *{border:none;margin:0px;padding:0px;}
.number{ padding: 36px 0 28px;width:400px;margin:auto}
.mui-numbox{ display: inline-block;}
.minus{width: 30px; height: 30px; text-align: center;border: solid 1px  #eaeaea; background: #f5f5f5; color: #9e9e9e;} 
.numbox{border-top: solid 1px  #eaeaea; border-bottom: solid 1px #eaeaea; height: 28px; width:60px; color: #333333; margin-left:-8px; text-align: center; background: transparent;}
.numbox::textfield-decoration-container {
    
}
.numbox::-webkit-inner-spin-button {
      -webkit-appearance: none;
}
.numbox::-webkit-outer-spin-button {
      -webkit-appearance: none;     /* 有无看不出差别 */
}
.plus { margin-left: -8px;}
  </style>
</head>
<body >
     <div class= "number" >
                                             购买数量:
                 <div class= "mui-numbox" >
                     <button class= "minus"  type= "button"  onclick= "opera('val', false);" >-</button>
                     <input class= "numbox"  type= "number"  id= "val"  value= "0" />
                     <button class= "minus plus"  type= "button"  onclick= "opera('val', true);" >+</button>
                     人次
                 </div>
     
         <script type= "text/javascript" >
     function  opera(x, y) {
         var  rs =  new  Number(document.getElementById(x).value);
         
         if  (y) {
             document.getElementById(x).value = rs + 1;
         else  if ( rs >0) {
             document.getElementById(x).value = rs - 1;
         }
         
     }
</script> 
</body>
</html>

效果预览:

wKiom1dS3TiQynyjAAAK7VpJ1Y4446.jpg-wh_50

本文转自  小旭依然  51CTO博客,原文链接:http://blog.51cto.com/xuyran/1786153

相关文章
|
4月前
|
存储 JavaScript 安全
TypeScript 中的 Number 类型,Number 类型的特性、常见操作和注意事项
TypeScript 中的 Number 类型,Number 类型的特性、常见操作和注意事项
182 1
|
16天前
|
前端开发 UED
CSS——如何取消a链接点击时的背景颜色
CSS——如何取消a链接点击时的背景颜色
8 1
|
1月前
|
存储
TS 自定义结构Long与number类型相互转换
TS 自定义结构Long与number类型相互转换
|
1月前
|
存储 JavaScript 前端开发
编程笔记 html5&css&js 066 JavaScript Number数据类型
编程笔记 html5&css&js 066 JavaScript Number数据类型
|
1月前
|
Web App开发 iOS开发
编程笔记 html5&css&js 026 HTML输入类型(2/2)
编程笔记 html5&css&js 026 HTML输入类型(2/2)
|
1月前
|
移动开发 数据安全/隐私保护 HTML5
编程笔记 html5&css&js 025 HTML输入类型(1/2)
编程笔记 html5&css&js 025 HTML输入类型(1/2)
|
3月前
|
前端开发 JavaScript
分享几个精美的网页按钮样式,纯CSS实现,无JS(拿来即用)
分享几个精美的网页按钮样式,纯CSS实现,无JS(拿来即用)
35 0
|
4月前
|
前端开发
(css必看)禁止用户拖动,禁止选中复制,禁止输入框输入
(css必看)禁止用户拖动,禁止选中复制,禁止输入框输入
99 1
|
4月前
|
前端开发 UED
Css 如何取消a链接点击时的背景颜色
Css 如何取消a链接点击时的背景颜色
|
4月前
|
前端开发
CSS 斜体按钮
CSS 斜体按钮
CSS 斜体按钮