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图片