css使用grid-area及clip-path实现不规则图片拼凑效果代码
代码语言:html
所属分类:布局界面
代码描述:css使用grid-area及clip-path实现不规则图片拼凑效果代码
代码标签: css grid-area clip-path 不规则 图片 拼凑
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <style> .gallery { --g: 6px; /* the gap */ display: grid; width: 450px; /* the size */ aspect-ratio: 1; grid: auto-flow 1fr/repeat(3,1fr); gap: var(--g); } .gallery img { width: 100%; height: 100%; object-fit: cover; filter: grayscale(); cursor: pointer; transition: .5s } .gallery img:hover { filter: grayscale(0); } .gallery img:nth-child(2) { grid-area: 1/2/span 2/span 2; clip-path: polygon(0 0,100% 0,100% 100%,calc(50% + var(--g)/4) 100%,0 calc(50% - var(--g)/4)) } .gallery img:nth-child(3) { grid-area: 2/1/span 2/span 2; clip-path: polygon(0 0,calc(50% - var(--g)/4) 0,100% calc(50% + var(--g)/4),100% 100%,0 100%); } body { m.........完整代码请登录后点击上方下载按钮下载查看
网友评论0