查看: 4373|回复: 0

[文章教程] css分隔线的五种方法

[复制链接]
ttasp 发表于 2015-3-25 15:37:32 | 显示全部楼层 |阅读模式
啥也不说,先上图片效果。好了同行们就收藏吧!





  1. <!DOCTYPE HTML>
  2. <html>
  3. <head>
  4. <meta charset="UTF-8" />
  5. <title>CSS巧妙实现分隔线的几种方法</title>
  6. <style>
  7. [url=home.php?mod=space&uid=597245]@charset[/url] "utf-8";
  8. body,h1,h2,h3,h4,p,ul,li,ol,dl,dt,dd,input,textarea,figure,form{margin:0;padding:0}
  9. body,input,textarea{font-size:12px;font-family:microsoft yahei}
  10. body{text-align:center;color:#33383D;}
  11. ul,ol{list-style:none}
  12. img{border:0}
  13. button,input {line-height:normal;*overflow:visible}
  14. input,textarea{outline:none}
  15. a{color:#3B8DD1;text-decoration:none}
  16. a:hover{color:#8CAC52}
  17. .demo-header{position:relative;height:22px;background-color:#33363B;line-height:22px;padding:2px 10px;text-align: left;}
  18. .demo-name{color: #ccc;}
  19. .demo-title,.demo-footer{height:0;overflow:hidden}
  20. .demo-container{clear: both;padding:40px 10px 20px;text-align:left;margin:0 auto;line-height: 18px;}
  21. .demo h2{font-size: 15px;padding-bottom: 6px;margin-bottom: 20px;border-bottom: solid 1px #ddd;}
  22. </style>
  23. </head>
  24. <body>

  25. <div class="demo-container demo">
  26. <style type="text/css">
  27. .demo{
  28. width: 600px;
  29. }
  30. .line_01{
  31.     padding: 0 20px 0;
  32.     margin: 20px 0;
  33.     line-height: 1px;
  34.     border-left: 200px solid #ddd;
  35.     border-right: 200px solid #ddd;
  36.     text-align: center;
  37. }
  38. .line_02{
  39.     height: 1px;
  40.     border-top: 1px solid #ddd;
  41.     text-align: center;
  42. }
  43. .line_02 span{
  44.     position: relative;
  45.     top: -12px;
  46.     background: #fff;
  47.     padding: 0 20px;
  48. }
  49. .line_03{
  50.     width:600px;
  51. }
  52. .line_03 b{
  53.     background: #ddd;
  54.     margin-top: 4px;
  55.     display: inline-block;
  56.     width: 180px;
  57.     height: 1px;
  58.     _overflow: hidden;
  59.     vertical-align: middle;
  60. }
  61. .line_03 span{
  62.     display: inline-block;
  63.     width: 220px;
  64.     vertical-align: middle;
  65. text-align: center;
  66. }
  67. .line_04{
  68.     width:600px;
  69. }
  70. .line_04{
  71.     overflow: hidden;
  72.     _zoom: 1;
  73. }
  74. .line_04 b{
  75.     background: #ddd;
  76.     margin-top: 12px;
  77.     float: left;
  78.     width: 26%;
  79.     height: 1px;
  80.     _overflow: hidden;
  81. }
  82. .line_04 span{
  83.     padding: 0 10px;
  84.     width: 32%;
  85.     float: left;
  86.     text-align: center;
  87. }
  88. .line_05{
  89.     letter-spacing: -1px;
  90.     color: #ddd;
  91. }
  92. .line_05 span{
  93.     letter-spacing: 0;
  94.     color: #222;
  95.     margin:0 20px;
  96. }
  97. </style>

  98. <div class="line_01">小小分隔线 单标签实现</div>
  99. <br>
  100. <br>
  101. <div class="line_02"><span>小小分隔线 巧用色实现</span></div>
  102. <br>
  103. <br>
  104. <div class="line_03"><b></b><span>小小分隔线 inline-block实现</span><b></b></div>
  105. <br>
  106. <br>
  107. <div class="line_04"><b></b><span>小小分隔线 浮动来实现</span><b></b></div>
  108. <br>
  109. <br>
  110. <div class="line_05">———————————<span>小小分隔线 字符来实现</span>————————————</div>
  111. <br>
  112. <br>
  113. </div>
  114. <div class="demo-footer">
  115. </div>
  116. </body>
  117. </html>
复制代码
您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表

在线客服

售前咨询
售后咨询
服务热线
023-58418553
微信公众号