css实现图片相册瀑布流悬浮拉伸效果代码

代码语言:html

所属分类:画廊相册

代码描述:css实现图片相册瀑布流悬浮拉伸效果代码,鼠标放上去,图片上下拉伸。

代码标签: css 图片 相册 瀑布 悬浮 拉伸

下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开

<!DOCTYPE html>
<html lang="en" >

<head>
  <meta charset="UTF-8">
  
<script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/tailwindcss.3.4.1.js"></script>
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@20..48,100..700,0..1,-50..200" />
  
  
  
<style>
*{
  padding: 0;
  margin: 0;
  box-sizing: border-box;
}
body{
  min-height: 100svh;
  display: grid;
  place-content: center;
  background: black;
  font-family: system-ui,sans-serif;
  padding: 2rem;
}
.material-fill-1 {
    font-variation-settings:
        'FILL'1,
        'wght'400,
        'GRAD'0,
        'opsz'48
}
.gallery {
    --_height: 250px; 
    --_gap: .5rem;
  
    --_grid-rows: var(--_height) var(--_height) var(--_height);
    --_height-hover: calc(var(--_height) * 2);
    --_height-not-hover: calc(var(--_height) / 2);
  
    width: 100%;  
    max-width: 800px;
    display: grid;
    gap: var(--_gap);
}
@media (min-width:720px){
  .gallery {
      grid-template-columns: repeat(3,1fr);
  }
  
}
.gallery>div {
    height: fit-content;
    display: grid;
    grid-template-rows: var(--_grid-rows);
    gap: var(--_gap);
    transition: grid-template-rows 300ms ease-in-out;
}
.gallery>div>article {
    position: relative;
}
.gallery>div>article>div{
   position: absolute;
  bottom: 0;
  left: 0;
  background: #00000070;
  font-size: 0.65rem;
  color: white;
  display: flex;
  align-items: center;
  gap: .25rem;
  padding: .15rem 0.5rem;
  
}
.gallery>div>article>div>span{
  font-size: 0.7rem;
  color: red;
}
.gallery img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.gallery>div:has(>article:nth-child(1):hover) {
    --_grid-rows: var(--_height-hover) var(--_height-not-hover) var(--_height-not-hover);
}
.gallery>div:has(>article:nth-child(2):hover) {
    --_grid-rows: var(--_height-not-hover) var(--_height-hover) var(--_height-not-hover);
}
.gallery>div:has(>article:nth-child(3):hover) {
    --_grid-rows: var(--_height-not-hover) var(--_height-not-hover) var(--_height-hover);
}
.gallery>div>article:hover {
    background-color: rgb(151, 152, 201);
    color: #FFF;
}
</style>


  
  
</head>

<body translate="no">
  <section class="gallery">
  <div>
    <article>
      <img src="https://images.pexels.com/photos/104842/bmw-vehicle-ride-bike-104842.jpeg?auto=compress&cs=tinysrgb&w=1260&h=750&dpr=1" alt="motorbike 1">
      <div><span class="material-symbols-outlined material-fill-1">favorite</span>12 Likes</div>
    </article>
    <article>
      <img src.........完整代码请登录后点击上方下载按钮下载查看

网友评论0