CSS/img:修订间差异

来自康健生活
< CSS
Kangkk​(留言 | 贡献)
Kangkk​(留言 | 贡献)
 
(未显示同一用户的4个中间版本)
第27行: 第27行:
}</syntaxhighlight>
}</syntaxhighlight>
[[文件:Img css cover 1.png|300px|none|无|Img css cover 1]]
[[文件:Img css cover 1.png|300px|none|无|Img css cover 1]]
== svg ==
svg 压缩
[https://github.com/svg/svgo SVGO] SVGOMG
base64 DataURI
== ICON ==
平移和竖移
<syntaxhighlight lang="css">
vertical-align: -3px;
transform: translateX(5px);</syntaxhighlight>
== 图片缩放 ==
<syntaxhighlight lang="css">
transform: scale(0.6,0.6);</syntaxhighlight>

2021年4月28日 (三) 04:45的最新版本

引言

在实际使用 img 标签中,如果父元素设定了 box 的宽和高,我们又不想让图片自动拉伸,那只能截取图片的一部分作为展示部分,原图如下

Img css cover 0
Img css cover 0

设定 css 属性

.list {
  float: left;
  background: white;
  height: $listHeight;
  margin: $latticeGutterWidth $latticeGutterWidth/2 0;
  overflow: hidden;

  &:nth-child(4n+1) {
    margin: $latticeGutterWidth $latticeGutterWidth/2 0 0;
  }

  &:nth-child(4n+4) {
    margin: $latticeGutterWidth 0 0 $latticeGutterWidth/2;
  }

  & > img {
    width: inherit;
    height: $listWidth*2/3;
    object-fit: cover;
    max-height: $listWidth*2/3 + 1;
  }
}
Img css cover 1
Img css cover 1

svg

svg 压缩

SVGO SVGOMG

base64 DataURI

ICON

平移和竖移

vertical-align: -3px;
transform: translateX(5px);

图片缩放

transform: scale(0.6,0.6);