單個標籤實現分隔線:spa
.demo_line_01{code
padding: 0 20px 0; margin: 20px 0; line-height: 1px; border-left: 200px solid #ddd; border-right: 200px solid #ddd; text-align: center;
}
優勢:代碼簡潔圖片
巧用背景色實現分隔線:ci
.demo_line_02{it
height: 1px; border-top: 1px solid #ddd; text-align: center;
}
.demo_line_02 span{io
position: relative; top: -8px; background: #fff; padding: 0 20px;
}
優勢:代碼簡潔,可自適應寬度class
inline-block實現分隔線:float
點此查看實例展現自適應
.demo_line_03{im
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;
}優勢:代碼簡潔 以上簡單介紹了分隔線的寫法,也許還有其它比較合適的寫法,看環境各取所需吧!