欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

用CSS和Div美化select樣式的簡(jiǎn)單方法

WEB前端開(kāi)發(fā)   發(fā)布時(shí)間:2015-08-06 18:05:39   作者:佚名   我要評(píng)論
這篇文章主要介紹了用CSS和Div美化SELECT樣式的簡(jiǎn)單方法,同時(shí)提到了select相關(guān)的兼容性寫(xiě)法,需要的朋友可以參考下

來(lái)直接看這個(gè)示例:

CSS Code復(fù)制內(nèi)容到剪貼板
  1. .select { margin: 0; padding: 0; border:1px solid #ccccccfloatleftdisplayinline; }   
  2. .select div { border:1px solid #f9f9f9floatleft; }   
  3. .select>div { overflowhidden; }   
  4. * html .select div select { display:blockfloatleftmargin: -2px; }   
  5. .select div>select { display:blockfloat:nonemargin: -2pxpadding0px; }   
  6. .select:hover { border:1px solid #666; }   

HTML

XML/HTML Code復(fù)制內(nèi)容到剪貼板
  1. <div class="select">  
  2.     <div>  
  3.         <select>  
  4.             <option>看見(jiàn)效果了吧</option>  
  5.             <option>看見(jiàn)效果了吧</option>  
  6.             <option>看見(jiàn)效果了吧</option>  
  7.         </select>  
  8.     </div>  
  9.     <div>  

看演示吧
demo

然后介紹一下全兼容select的寫(xiě)法

先看下select屬性表
201586181141057.jpg (790×354)

通過(guò)上述的研究成果屬性匯總,我們知道IE6是無(wú)論如何設(shè)置都是固定高度為22px不變的,而其他瀏覽器除safari都是支持height屬性的,那么我們?cè)O(shè)置 height:22px。那么現(xiàn)在我們修正一下safari瀏覽器,,我們發(fā)現(xiàn)僅有safari支持line-height屬性那么正好可以利用line-height修正其高度為22px,在font-size為12px的前提下設(shè)置 line-height:22px,最后FF和IE9里面的文字不居中,對(duì)其設(shè)定 padding:2px 0,我們發(fā)現(xiàn)FF和IE9都居中了,但是各個(gè)瀏覽器的select的高度也并沒(méi)有增加,那么這里有點(diǎn)疑問(wèn),在高度設(shè)定的情況下,小量數(shù)字的padding不增加整體高度?

下面是全兼容代碼示例。

 

CSS Code復(fù)制內(nèi)容到剪貼板
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">   
  2. <html xmlns="http://www.w3.org/1999/xhtml">   
  3. <head>   
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />   
  5. <title>demo</title>   
  6. <style>   
  7. *{padding:0; margin:0}   
  8. body{font-size:12px}   
  9. select{height:22pxline-height:18pxpadding:2px 0}   
  10. </style>   
  11. </head>   
  12. <body>   
  13. <div style="margin-top:20px; margin-left:20px; background:#000">   
  14. <select>   
  15.     <option>演示問(wèn)題一</option>   
  16.     <option>演示問(wèn)題二</option>   
  17.     <option>演示問(wèn)題三</option>   
  18.     <option>演示問(wèn)題四</option>   
  19.     <option>演示問(wèn)題五</option>   
  20. </select>   
  21. </div>   
  22. </body>   
  23. </html>  

demo 

相關(guān)文章

最新評(píng)論