當前位置:軟件學(xué)堂 > 資訊首頁 > 網(wǎng)絡(luò)編程 > DIV+CSS > 圖片設(shè)置不同的邊框CSS樣式

圖片設(shè)置不同的邊框CSS樣式

2012/11/24 13:10:09作者:佚名來源:網(wǎng)絡(luò)

移動端

【實例介紹】

圖片設(shè)置不同的邊框CSS樣式

設(shè)置方法是使一個圖片的4條邊框具有同樣的效果。在CSS中我們也可以對4條邊框分別設(shè)置,只需要分別設(shè)置border-left、border-right、border-top和border-bottom的樣式即可。

【案例代碼】

<html xmlns="http://www.w3.org/1999/xhtml">
   <head>
      <title>圖像</title>
<style type="text/css">
img{
 border-left-style:dotted; /* 左點畫線 */
 border-left-color:#3300FF; /* 左邊框顏色 */
 border-left-width:4px;  /* 左邊框粗細 */
 border-right-style:dashed;
 border-right-color:#FF0000;
 border-right-width:2px;
 border-top-style:solid;  /* 上實線 */
 border-top-color:#CC44FF; /* 上邊框顏色 */
 border-top-width:1px;  /* 上邊框粗細 */
 border-bottom-style:groove;
 border-bottom-color:#66cc66;
 border-bottom-width:3px;
}
</style>
   </head>
   <body>
      <img src="car.jpg" >
   </body>
</html>

 

【代碼分析】

顯示效果如圖所示,圖片的4個邊框都設(shè)置了不同的樣式。實際運用中各條邊框的設(shè)置基本上是相同的,只有個別樣式不一樣。這時就可以進行統(tǒng)~設(shè)置,再針對個別的邊框特殊設(shè)置,如下面案例的設(shè)置方法。

設(shè)置不同的邊框樣式運行效果

【實例代碼】

<style type="text/css"> img{  border-style:dashed;  border-width:2px;  border-color:#0000FF;  border-left-style:solid;   border-top-width:4px;    border-right-color:#FF0000;    } </style>

 

【代碼分析】

在瀏覽器中的效果如圖所示,這個案例先對4條邊框統(tǒng)一設(shè)置,然后分別對左邊的線翌上邊框的寬度和右邊框的顏色進行特殊設(shè)置。

設(shè)置不同的邊框樣式運行效果

 【素材及源碼下載】

請點擊:設(shè)置不同的邊框CSS樣式 下載本實例相關(guān)素材及源碼

 

標簽: 圖片  設(shè)置不同  邊框