常用CSS笔记原创

原创
小哥 3年前 (2022-10-17) 阅读数 167 #CSS教程
文章标签 CSS

grid 常用属性用法记录常用属性用法记录

display: grid;
grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
grid-template-rows: 140px 140px;
gap: 10px;
overflow: hidden;
grid-template-areas:
“a b c d e”
“f f g h i”;

图片居中

方法1

div{
    position:relative;
  width: 100px;
    height: 100px;
    overflow:hidden;
}
 div img{
    position: absolute;
    top: 50%;
    left: 50%;
    display: block;
    min-width: 100%;
    min-height: 100%;
    transform:translate(-50%,-50%);
}

方法2

div{
  width: 100px;
  height: 100px;

}
div img{
    width: 100%;
    height: 100%;
    object-fit:cover;
}
版权声明

所有资源都来源于爬虫采集,如有侵权请联系我们,我们将立即删除

热门