今天主要學習CSS3中的邊框(Border). 這對我們來說並不陌生.多少次寫下 border:1px solid red了..那麼CSS3中會給我們帶來什麼驚喜呢?
在CSS3中.邊框多了4種新功能
Border-color(設定邊框顏色)
Border-image(透過圖片設定為邊框)
Border-radius(邊框的半徑)
box-shadow(陰影效果)
用CSS3,你可以建立圓角邊框,加入陰影框,並作為邊界的圖像而不使用設計程式
##CSS3圓角border-radius屬性
CSS3圓角只需設定一個屬性:border-radius(意義是"邊框半徑")。你為這個屬性提供一個值,就能同時設定四個圓角的半徑。所有合法的CSS度量值都可以使用:em、ex、pt、px、百分比等等。
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>php中文网(php.cn)</title> <style type="text/css"> div { border:2px solid #a1a1a1; padding:10px 40px; background:yellow; width:300px; height:300px; border-radius:25px 15px 40px 0; } </style> </head> <body> <div>观察4个角的不同 </div> </body> </html>
CSS3盒子陰影box-shadow屬性#
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>php中文网(php.cn)</title> <style type="text/css"> .border_test { border:5px solid red; -moz-box-shadow:5px 2px 6px black; -ms-box-shadow:5px 2px 6px black; -wekit-box-shadow:5px 2px 6px black; -o-box-shadow:5px 2px 6px black; box-shadow:5px 2px 6px black; } </style> </head> <body> <div class='border_test'>CSS3 Border-shadow样式</div> </body> </html>
CSS3邊界圖片Border-image
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>php中文网(php.cn)</title> <style type="text/css"> .border_test { -webkit-border-image: url(http://pic002.cnblogs.com/images/2012/455414/2012101316502564.jpg) 0 12 0 12 stretch stretch; -moz-border-image: url(http://pic002.cnblogs.com/images/2012/455414/2012101316502564.jpg) 0 12 0 12 stretch stretch; -o-border-image: url(http://pic002.cnblogs.com/images/2012/455414/2012101316502564.jpg) 0 12 0 12 stretch stretch; -ms-border-image: url(http://pic002.cnblogs.com/images/2012/455414/2012101316502564.jpg) 0 12 0 12 stretch stretch; -border-image: url(http://pic002.cnblogs.com/images/2012/455414/2012101316502564.jpg) 0 12 0 12 stretch stretch; display: block; border-width: 0 12px; padding: 10px; text-align: center; font-size: 26px; text-decoration: inherit; color:white; } </style> </head> <body> <div class='border_test'>CSS3 Border-image样式</div> </body> </html>