實現css虛線樣式的兩種方式:dotted和dashed(執行個體)

來源:互聯網
上載者:User
css虛線邊框怎麼做?html虛線邊框設定一般會想到border的solid,html網頁布局中solid用的機率最高了,要有css虛線的效果還可以用圖片做背景,但是不推薦,盡量使用css虛線樣式做這個虛線的效果, 那麼css虛線樣式就是border中的dotted和dashed,這兩種都是css虛線,但是他們是有區別的,請看下面css虛線邊框代碼執行個體用法示範。

css虛線樣式實現方式一:dotted虛線

<!Doctype html><html><head><meta http-equiv="Content-Type" content="text/html; charset=gbk2312"/><title>dotted虛線</title><style type="text/css">*{margin:100px;padding:0;}body{width:1000px;margin:0 auto;}.box{width:300px;height:50px;text-align:center;padding-top:30px;border:1px dotted #000;}</style></head><body><div class="box">大家好,我是dotted虛線!</div></body></html>

dotted虛線顯示效果:

css虛線樣式二:dashed虛線

<!Doctype html><html><head><meta http-equiv="Content-Type" content="text/html; charset=gbk2312"/><title>dashed虛線</title><style type="text/css">*{margin:100px;padding:0;}body{width:1000px;margin:0 auto;}.box{width:300px;height:50px;text-align:center;padding-top:30px;border:1px dashed #000;}</style></head><body><div class="box">大家好,我是dashed虛線!</div></body></html>

dashed虛線顯示效果:

css虛線樣式border中的dotted和dashed區別:

dashed:來自 dash(破折號),由 dash 組成的虛線

dotted:來自 dot (點),由 dot 組成的虛線,也稱點線

上面的示範也能直觀的看出來他們的區別

相關文章

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.