博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
常用的input样式美化。
阅读量:4627 次
发布时间:2019-06-09

本文共 2010 字,大约阅读时间需要 6 分钟。

在平常的网站开发中,css,html提供的关于<input type ="checkbox"/>或者<input type = "file"/>的样式不是我们想要的,那么现在我们来介绍一个小技巧,来设置成我们想要的样式。

第一个input框的美化,原理是用一个a标签包裹一个input标签,让input溢出,设置input标签的透明度为0,然后设置a标签就可以设置显示的样式了

DOM结构:

css代码:

1 .up-file { 2     padding: 4px 10px; 3     height: 40px; 4     width: 240px; 5     text-align: center; 6     line-height: 40px; 7     position: relative; 8     cursor: pointer; 9     background: #44bbff;10     color: #FFFFFF;11     border: 1px solid #ddd;12     border-radius: 4px;13     overflow: hidden;14     display: inline-block;15     *display: inline;16     *zoom: 1;17 }18 .up-file input {19     position: absolute;20     font-size: 100px;21     right: 0;22     top: 0;23     opacity: 0;24     filter: alpha(opacity=0);25     cursor: pointer;26 }

第二个的话,需要涉及到js的功能,其实我们看到的并不是checkbox,而是我们点击的时候将其背景图片位置改变,看上去就像是美化了一样

1 
2
3
1 .select-pro {2     padding-left: 10px;3     background: url(../img/icon-important.png)no-repeat;4     background-position: 0 center;5 }
1 var one = document.getElementById("promise1").getElementsByTagName("label")[0]; 2 var two = document.getElementById("two").getElementsByTagName("label")[0]; 3 var three = document.getElementById("address").getElementsByTagName("label")[0]; 4 var identi = document.getElementById("identi").getElementsByTagName("div"); 5 var makesure = document.getElementById("makesure"); 6 var Count1 = 0; 7 var Count2 = 0; 8 var Count3 = 0; 9 var len = identi.length;10 one.onclick = function() {11     if (Count1 % 2 == 0) {12         one.style.backgroundPositionY = "67%";13     } else {14         one.style.backgroundPositionY = "90%";15     }16     Count1++;17 }18 two.onclick = function(){19     two.style.backgroundPositionY = "-25px";20     three.style.backgroundPositionY = "0";21 }22 three.οnclick=function(){23     three.style.backgroundPositionY = "-25px";24     two.style.backgroundPositionY = "0";25 }26 27 for(var i = 0;i

纯属原创,如若转载,请声明出处。

转载于:https://www.cnblogs.com/programerHuan/p/4857407.html

你可能感兴趣的文章
hustwinterC - Happy Matt Friends(dp解法)
查看>>
手机滚动条拖动
查看>>
Linux下C语言使用openssl库进行加密
查看>>
settTimeout vs setInterval
查看>>
Vista, the evil OS in the world
查看>>
Leetcode 80.删除排序数组中的重复项 II By Python
查看>>
常用JS加密编码算法
查看>>
spring boot中常用的配置文件的重写
查看>>
【线性规划和网络流24题】
查看>>
犹抱琵琶半遮面-OC
查看>>
标题颜色
查看>>
Python学习--和 Oracle 交互(2)
查看>>
VxWorks启动过程详解(上) 分类: vxWorks ...
查看>>
GJB150-2009军用装备实验室环境试验方法新版标准
查看>>
js面象对象插件+历史管理
查看>>
Spark学习体系整理(基础篇、中级篇、高级篇所涉及内容)
查看>>
网络编程之进程3
查看>>
Visual Studio Code 工具使用教程
查看>>
linux下shellcode编写入门
查看>>
selenium入门环境之浏览器问题
查看>>