去掉或者修改 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