教学之友,学习之友。

站长教学网

当前位置: 站长教学网 > 前端开发 > CSS教程 >

你应该知道的30个实用CSS代码(3)

时间:2012-03-25 20:25来源:未知 作者:ken 点击:

7. Drop Caps

非常棒的跨浏览器代码帮助你使得每段文字的第一个字母更加

  1. .firstcharacter { float: left; color: #903; font-size: 75px; line-height: 60px; padding-top: 4px; padding-right: 8px; padding-left: 3px; font-family: Georgia; } 

明显CSS3也可以,但是不支持IE9

  1. p:first-child:first-letter { floatleftcolor#903font-size75pxline-height60pxpadding-top4pxpadding-right8pxpadding-left3pxfont-family: Georgia; } 

8. CSS Sticky Footer

CSS实现的置顶sticky页脚效果,支持所有的主流浏览器包括chrome和IE8

CSS:

  1. /*  
  2. Sticky Footer Solution  
  3. by Steve Hatcher   
  4.  
  5. http://stever.ca  
  6.  
  7. http://www.cssstickyfooter.com  
  8.  
  9. */ 
  10.  
  11. * {margin:0;padding:0;}   
  12.  
  13. /* must declare 0 margins on everything, also for main layout components use padding, not  
  14. vertical margins (top and bottom) to add spacing, else those margins get added to total height  
  15. and your footer gets pushed down a bit more, creating vertical scroll bars in the browser */ 
  16.  
  17. html, body {height100%;}  
  18.  
  19. #wrap {min-height100%;}  
  20.  
  21. #main {overflow:auto;  
  22.     padding-bottom150px;}  /* must be same height as the footer */ 
  23.  
  24. #footer {positionrelative;  
  25.     margin-top-150px/* negative value of footer height */ 
  26.     height150px;  
  27.     clear:both;}   
  28.  
  29. /*Opera Fix*/ 
  30. body:before {/* thanks to Maleika (Kohoutec)*/ 
  31. content:"";  
  32. height:100%;  
  33. float:left;  
  34. width:0;  
  35. margin-top:-32767px;/* thank you Erik J - negate effect of float*/ 
  36. }  
  37.  
  38. /* IMPORTANT  
  39.  
  40. You also need to include this conditional style in the  of your HTML file to feed this style to IE 6 and lower and 8 and higher.  
  41.  
  42. <!--[if !IE 7]>  
  43. <style type="text/css">  
  44.         #wrap {display:table;height:100%}  
  45.     </style>  
  46.  
  47. < ![endif]-->  
  48.  
  49. */ 

HTML:

  1. <div id="wrap"> 
  2.  
  3.     <div id="main"> 
  4.  
  5.     </div> 
  6.  
  7. </div> 
  8.  
  9.  
  10. <div id="footer"> 
  11.  
  12. </div> 

9. Image Replacement Technique

实用的图片替换文字页面元素效果。

  1. a.replacement  
  2. {  
  3.   backgroundurl(dotted-border.png) no-repeat;  
  4.   height44px;  
  5.   width316px;  
  6.   displayblock;  
  7.   text-indent-9999px;  
  8.   overflowhidden;  /*Add this line to the image replacement method*/ 

10. Set body font-size to 62.5% for Easier em Conversion

如果你想拥有更加灵活的布局,你应该使用em而不是pixel或者points。通过设置你的字体62.5%,你可以很容易的通过设置em为pixel的1/10来设置文字。

  1. body {  
  2.   font-size62.5%/* font-size 1em = 10px */ 
  3. }  
  4. p {  
  5.   font-size1.2em/* 1.2em = 12px */ 

(责任编辑:ken)

TAG标签:
顶一下
(0)
0%
踩一下
(0)
0%
------分隔线----------------------------
发表评论
请自觉遵守互联网相关的政策法规,严禁发布色情、暴力、反动的言论。
评价:
表情:
注册登录:不允许匿名留言,登录后留言无需输入验证码。
栏目列表
最新内容