去掉或者修改 input、select 等表单的【默认样式 】


隐藏input等表单的默认样式的背景:

textarea,select,input{-webkit-appearance: none; -moz-appearance: none; -o-appearance: none; appearance: none;}

 

让div看起来像按钮:

div
{
appearance:button;
-moz-appearance:button; /* Firefox */
-webkit-appearance:button; /* Safari 和 Chrome */
}

 

使用css打造自定义select(非模拟)实现原理及样式

 

 点评:使用appearance:none去除select的默认样式,配合使用gradient、background-size,background-position,拼出自定义的样式,大家可以发挥想象力做出绚丽的select 实现原理很简单
1,使用appearance:none去除select的默认样式;
2,配合使用gradient、background-size,background-position,拼出自定义的样式
我定义的样式和浏览器默认给出的样式没多大差别,主要是简单实现一下,大家可以发挥想象力做出绚丽的select。

实现css如下

  代码如下:

  select{
margin: 0;
padding: 0;
outline: none;
height: 25px;
line-height: 25px;
width: 120px;
border: rgb(191, 204, 220) 1px solid;
border-radius: 3px;
display: inline-block;
font: normal 12px/25px "微软雅黑", "SimSun", "宋体", "Arial";
background-size: 5px 5px,5px 5px,25px 25px,1px 25px;
background-color: #fff;
background-image: repeating-linear-gradient(225deg,rgb(105,123,149) 0%,rgb(105,123,149) 50%,transparent 50%,transparent 100%),
repeating-linear-gradient(135deg,rgb(105,123,149) 0%,rgb(105,123,149) 50%,transparent 50%,transparent 100%),
linear-gradient( #FFFFFF 0%,#F8F9Fd, #EFFAFA 100%),
repeating-linear-gradient( rgb(191, 204, 220) 0%,rgb(191, 204, 220) 100%);
background-repeat: no-repeat;
background-position: 101px 10px,106px 10px,right top,92px top;
-webkit-appearance: none
}

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM