css——做border小於1px的邊框


參考: https://blog.csdn.net/Tyro_java/article/details/52013531

 

效果:

 

 

方法:利用 偽元素 + 縮放

注:我的頁面是vue頁面,使用v-for渲染的

頁面:

<p class="p-tag" v-if="labelList.length>0">
  <span class="tag" :con="data.labelname" v-for="data in labelList">{{data.labelname}}</span>
</p>

css:

.p-tag {
  width: 100%;
  height: .18rem;
  line-height: .18rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: #ff6801;
}

.p-tag .tag {
  margin-right: 4px;
}

.tag {
  display: inline-block;
  color: transparent;
  position: relative;
}

.tag:after {
  content: attr(con);
  position: absolute;
  left: 0;
  top: 0;
  width: 190%; //注意這個寬度,不要為200%,不然會出現有的邊框邊緣顯示不全問題
  height: 200%;
  background-color: #FFFFFF;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  color: #ff6801;
  font-size: .2rem;
  text-align: center;
  border: 1px solid #ff6801;
  border-radius: 15px;
  -webkit-transform-origin: 0 0;
  transform-origin: 0 0;
  -webkit-transform: scale(.5, .5);
  transform: scale(.5, .5);
}

.tag:after {
  font-size: .24rem;
}

.tag:last-child,
.p-tag.tag:last-child {
  margin-right: 0;


免責聲明!

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



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