<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    posts - 431,  comments - 344,  trackbacks - 0

    原文地址:http://webdevmania.com/archive/top_10_css_snippets/

    I have noticed myself to use a few different code snippets on a daily basis so I thought some of you might find them useful. So here we go.

       
    1.    
      center     
      Centering a website (or other elements)
         
      The HTML
      1. <DIV class=wrap>  
      2. </DIV><!-- end wrap -->  

      The CSS

       

      1. .wrap { width:960pxmargin:0 auto;}   

       

      This is an oldie, but apperantly it is not as obvious as you would think.

       

    2.  


    3.    
      stickyfooter

         
      Sticky Footer (make footer always be on bottom without absolute positioning)

       
      The HTML

       

      1. <DIV id=wrap>  
      2.   
      3. <DIV id=main class=clearfix>  
      4.   
      5. </DIV>  
      6.   
      7. </DIV>  
      8.   
      9. <DIV id=footer>  
      10.   
      11. </DIV>  

      The CSS

       

      1. * { margin:0padding:0; }    
      2.   
      3. html, body, #wrap { height100%; }   
      4.   
      5. body > #wrap {heightautomin-height100%;}   
      6.   
      7. #main { padding-bottom150px; }  /* must be same height as the footer */  
      8.   
      9. #footer {   
      10.         positionrelative;   
      11.  margin-top-150px/* negative value of footer height */  
      12.  height150px;   
      13.  clear:both;}    
      14.   
      15. /* CLEAR FIX*/  
      16. .clearfix:after {content".";   
      17.  displayblock;   
      18.  height0;   
      19.  clearboth;   
      20.  visibilityhidden;}   
      21. .clearfix {display: inline-block;}   
      22. /* Hides from IE-mac */  
      23. * html .clearfix { height1%;}   
      24. .clearfix {displayblock;}   
      25. /* End hide from IE-mac */  

       

      As of recently i have had to use this over 50 times… i think this is one of the most important tricks you will learn today.

       

    4.  


    5.    
      min-height

         
      Cross-Browser Min Height

       
      The CSS

       

      1. .element { min-height:600pxheight:auto !importantheight:600px; }   

       

      You can replace the min-height and heigth with 12em or another value that works for you.

       

    6.  


    7.    
      box-shadow

         
      Box Shadow (CSS3)

       
      The CSS

       

      1. .box { box-shadow: 5px 5px 5px #666;  -moz-box-shadow: 5px 5px 5px #666;  -webkit-box-shadow: 5px 5px 5px #666; }   

       

      As you can see since this is a CSS3 property you will need all the three commands to make it cross browser(except for ie of course). The first 2 measurements are for horizontal offset and the vertical offset. The third number is for the blur radius. And the last is the color of the shadow.

       

    8.  


    9.    
      text-shadow

         
      Text Shadow (CSS3) with IE hack

       
      The CSS

       

      1. .text { text-shadow1px 1px 1px #666; filter: Shadow(Color=#666666, Direction=135, Strength=5); }   

       

      This technique is great for all modern browsers, the IE fix works but it is not amazing quality.

       

    10.  


    11.    
      opac

         
      Cross Browser CSS Opacity

       
      The CSS

       

      1. .transparent {   
      2.      
      3.   /* Modern Browsers */ opacity: 0.7;   
      4.   
      5.   /* IE 8 */ -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=70)";   
      6.   
      7.   /* IE 5-7 */ filter: alpha(opacity=70);   
      8.   
      9.   /* Netscape */ -moz-opacity: 0.7;   
      10.   
      11.   /* Safari 1 */ -khtml-opacity: 0.7;   
      12.      
      13. }   

       

      Opacity can be used for plenty of elements, it adds a certain new age style we all strive for. Notice that in some browsers transperancy is inherited by all child elements!

       

    12.  


    13.    
      reset

         
      The Famous Meyer Reset

       
      The CSS

       

      1.   html, body, div, span, applet, object, iframe,   
      2. h1, h2, h3, h4, h5, h6, p, blockquote, pre,   
      3. a, abbr, acronym, address, big, cite, code,   
      4. del, dfn, em, font, img, ins, kbd, q, s, samp,   
      5. small, strike, strong, sub, sup, tt, var,   
      6. dl, dt, dd, ol, ul, li,   
      7. fieldset, form, label, legend,   
      8. table, caption, tbody, tfoot, thead, tr, th, td {   
      9.  margin0;   
      10.  padding0;   
      11.  border0;   
      12.  outline0;   
      13.  font-weight: inherit;   
      14.  font-style: inherit;   
      15.  font-size100%;   
      16.  font-family: inherit;   
      17.  vertical-alignbaseline;   
      18. }   
      19. /* remember to define focus styles! */  
      20. :focus {   
      21.  outline0;   
      22. }   
      23. body {   
      24.  line-height1;   
      25.  colorblack;   
      26.  backgroundwhite;   
      27. }   
      28. ol, ul {   
      29.  list-stylenone;   
      30. }   
      31. /* tables still need 'cellspacing="0"' in the markup */  
      32. table {   
      33.  border-collapseseparate;   
      34.  border-spacing0;   
      35. }   
      36. caption, th, td {   
      37.  text-alignleft;   
      38.  font-weightnormal;   
      39. }   
      40. blockquote:before, blockquote:after,   
      41. q:before, q:after {   
      42.  content"";   
      43. }   
      44. blockquote, q {   
      45.  quotes"" "";   
      46. }   
      47.    

       

      This is the most useful css reset out there, i use it for almost everything I work on (even the 52framework, coming soon).

       

    14.  


    15.    
      dotted

         
      Removing the dotted outlines

       
      The CSS

       

      1. a, a:active { outlinenone; }   

       

      I find myself getting very annoyed with the dotted outline (especially for text-indented elements that are off the page).

       

    16.  


    17.    
      rounded

         
      Rounded Corners (non ie)

       
      The CSS

       

      1. .element {   
      2.  -moz-border-radius: 5px;   
      3.  -webkit-border-radius: 5px;   
      4.  border-radius: 5px/* future proofing */  
      5. }   
      6. .element-top-left-corner {   
      7.  -moz-border-radius-topleft: 5px;   
      8.  -webkit-border-top-left-radius: 5px;   
      9. }   

       

      Love rounded corners? Don’t want to slave over images and elements to get the effect? This is your solution, and elements still look fine in ie.

       

    18.  


    19.    
      import

         
      Override Inline Styles

       
      The CSS

       

      1. .override {   
      2.  font-size14px !important;   
      3. }   

       

      This comes in handy plenty of times, I personally use it way too much smile everytime something doesn’t work I test if its just not being applied because of some other style.

    posted on 2010-01-04 08:46 周銳 閱讀(333) 評論(0)  編輯  收藏 所屬分類: CSS
    主站蜘蛛池模板: 亚洲AV日韩综合一区尤物 | 久久久高清日本道免费观看| 国产无遮挡吃胸膜奶免费看| gogo全球高清大胆亚洲| 亚洲欧美日韩久久精品| 德国女人一级毛片免费| 亚洲youwu永久无码精品| 日本无吗免费一二区| 亚洲暴爽av人人爽日日碰| 国产片免费在线观看| 美女尿口扒开图片免费| 亚洲国产精品人人做人人爱| 亚洲美女免费视频| 国内成人精品亚洲日本语音| 国产成人高清精品免费软件| 免费看一级一级人妻片| 国产精品亚洲mnbav网站| 久久国产精品国产自线拍免费| 亚洲va无码专区国产乱码| 99ee6热久久免费精品6| 亚洲免费视频播放| 国产精品酒店视频免费看| a免费毛片在线播放| 日韩毛片免费无码无毒视频观看 | 国产亚洲无线码一区二区| 久久久久久亚洲精品影院| 看全色黄大色大片免费久久| 新最免费影视大全在线播放| 亚洲国产精品无码久久久不卡 | 国产国产人免费视频成69堂| 在线播放亚洲第一字幕| 久久久久久影院久久久久免费精品国产小说 | 日本免费高清一本视频| 一个人看的www在线免费视频| 成人黄动漫画免费网站视频 | 亚洲AV无码一区二区三区电影| 亚洲精品WWW久久久久久| 无码日韩精品一区二区免费暖暖 | 好先生在线观看免费播放| 又黄又大的激情视频在线观看免费视频社区在线 | 国产精品亚洲A∨天堂不卡|