CSS巧妙實現分隔線的幾種方法

來源:互聯網
上載者:User

標籤:

單個標籤實現分隔線:

 

點此查看執行個體展示

 

.demo_line_01{    padding: 0 20px 0;    margin: 20px 0; line-height: 1px; border-left: 200px solid #ddd; border-right: 200px solid #ddd; text-align: center;}

優點:代碼簡潔

巧用背景色實現分隔線:

 

點此查看執行個體展示

 

.demo_line_02{    height: 1px;    border-top: 1px solid #ddd; text-align: center;}.demo_line_02 span{ position: relative; top: -8px; background: #fff; padding: 0 20px;}

優點:代碼簡潔,可自適應寬度

inline-block實現分隔線:

 

點此查看執行個體展示

 

.demo_line_03{    width:600px;}.demo_line_03 b{    background: #ddd; margin-top: 4px; display: inline-block; width: 180px; height: 1px; _overflow: hidden; vertical-align: middle;}.demo_line_03 span{ display: inline-block; width: 220px; vertical-align: middle;}

優點:文字可多行

浮動實現分隔線:

 

點此查看執行個體展示

 

.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;}

優點:NUN

利用字元實現分隔線:

 

點此查看執行個體展示

 

<div class="demo_line_05">———————————<span>小小分隔線 字元來實現</span>————————————</div>
.demo_line_05{    letter-spacing: -1px;    color: #ddd;}.demo_line_05 span{ letter-spacing: 0; color: #222; margin:0 20px;}

優點:代碼簡潔 以上簡單介紹了分隔線的寫法,也許還有其它比較合適的寫法,看環境各取所需吧!

文章來自:http://www.daqianduan.com/4258.html

CSS巧妙實現分隔線的幾種方法

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.