前段經常使用功能

破裂的圖片

img {  
  /* Same as first example */
  min-height: 50px;
}

img:before {  
  content: " ";
  display: block;

  position: absolute;
  top: -10px;
  left: 0;
  height: calc(100% + 10px);
  width: 100%;
  background-color: rgb(230, 230, 230);
  border: 2px dotted rgb(200, 200, 200);
  border-radius: 5px;
}

img:after {  
  content: "\f127" " Broken Image of " attr(alt);
  display: block;
  font-size: 16px;
  font-style: normal;
  font-family: FontAwesome;
  color: rgb(100, 100, 100);

  position: absolute;
  top: 5px;
  left: 0;
  width: 100%;
  text-align: center;
}

破裂的圖片

長單詞處理css

.hyphenate {
    overflow-wrap: break-word;
    word-wrap: break-word;
    hyphens: auto;
}

圖片自適應

圖片等比例縮放自動適應img大小,可能留有空隙spa

img {
    object-fit: contain;
}

圖片自適應

圖片等比例縮放自動適應填充img大小,code

img {
    object-fit: cover;
}

圖片自適應

還有個none值,保持原有尺寸比例。同時保持替換內容原始尺寸大小。orm

轉載地址https://gold.xitu.io/entry/578639d28ac2470060526879圖片

相關文章
相關標籤/搜索