这篇 文章 整理css如何实现文章分割线的多种方式,分割线在页面中可以起到美化作用,那么就来看看使用css实现分割线样式的多种方法。效果如下:
方式一:单个标签实现分隔线:
ht ML :
<div class="line_01">小小分隔线 单标签实现</div>
css:
.demo_line_01{ padding: 0 20px 0; m arg in: 20px 0; line-h ei ght: 1px; border-left: 190px solid # ddd; border-right: 190px solid #ddd; text-align: center ; }
优点:代码简洁
方式二、巧用背景色实现分隔线:
html:
<div class="line_02"><span>小小分隔线 巧用色实现</span></div>
css:
.demo_line_02{ height: 1px; border -t op: 1px solid #ddd; text-align: center; } .demo_line_02 span{ pos IT ion: relative; top: -8px; background: #fff; padding: 0 20px; }
优点:代码简洁,可自适应 宽 度
方式三、inline-block实现分隔线:
html:
<div class="line_03"><b></b><span>小小分隔线 inline-block实现</span><b></b></div>
css:
.demo_line_03{ width:600px; } .demo_line_03 b{ background: #ddd; mar gin -top: 4px; dis play : inline-block; width: 180px; height: 1px; _overflow: hidden; vert ical -align: middle; } .demo_line_03 span{ display: inline-block; width: 220px; vertical-align: middle; }
方式四、浮动实现分隔线:
html:&nbs p;
<div class="line_04"><b></b><span>小小分隔线 浮动来实现</span><b></b></div>
css:
.demo_line_04{ width:600px; } .demo_line_04{ overflow: hidden; _zoom: 1; } .demo_line_04 b{ background: #ddd; margin-top: 8px; float: left; width: 26%; height: 1px; _overflow: hidden; }
方式五、 利用 字符实现分隔线:
html:
<div class="line_05">———————————<span>小小分隔线 字符来实现</span>————————————</div>
css:
.demo_line_05{ letter -s pacing: -1px; color: #ddd; } .demo_line_05 span{ letter-spacing: 0; color: #222; margin:0 20px; }
优点:代码简洁 以上 简单 介绍了分隔线的写法,也许还有其它比较合适的写法,看环境各取所需吧!
到此这篇关于css实现文章分割线样式的多种方法总结的文章就介绍到这了,更多相关css分割线样式内容请搜索以前的文章或继续浏览下面的相关文章,希望大家以后多多支持!
总结
以上是 为你收集整理的 css实现文章分割线样式的多种方法总结 全部内容,希望文章能够帮你解决 css实现文章分割线样式的多种方法总结 所遇到的问题。
如果觉得 网站内容还不错, 推荐好友。
查看更多关于css实现文章分割线样式的多种方法总结的详细内容...
声明:本文来自网络,不代表【好得很程序员自学网】立场,转载请注明出处:http://haodehen.cn/did201780