css做八邊形圖片有邊框


用css樣式實現,八邊形圖片有邊框並邊框和圖片有間距的,請多多指教
css部分

.pictrue{
  box-sizing: border-box;
  position: relative;
  width: 400px;
  height: 400px;
  transform: rotate(45deg);
  overflow: hidden;
}
.pictrue .item{
  box-sizing: border-box;
  padding: 10px;
  position: absolute;
  width: 100%;
  height: 100%;
  content:" ";
  transform: rotate(-45deg);
  border: 1px solid red;
  overflow: hidden;
  background-color: #fff;
}
.pictrue .item:after{
  position: absolute;
  top: -1px;
  left: -1px;
  content:" ";
  width: 100%;
  height: 100%;
  transform: rotate(135deg);
  border: 1px solid red;
}
.pictrue .item:before{
  position: absolute;
  left: 0;
  top: 0;
  box-sizing: border-box;
  content:" ";
  width: 100%;
  height: 100%;
  transform: rotate(135deg);
  border: 10px solid #fff;
}
.pictrue .item img{
  max-width: 100%;
}

html部分

<div class="pictrue">
  <div class="item">
    <img src="01.jpg">
  </div>
</div>

效果圖

 

 

 

01.jpg

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM