
演 示
免费下载
简介
```
##### CSS样式
画廊采用flex进行布局,这个画廊设置最大宽度和100%的视口高度。
```html
.gallery{
width: 100%;
max-width: 960px;
min-height: 100vh;
margin: 2rem auto;
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
-webkit-flex-wrap: wrap;
-ms-flex-wrap: wrap;
flex-wrap: wrap;
-webkit-box-pack: center;
-webkit-justify-content: center;
-ms-flex-pack: center;
justify-content: center;
}
```
画廊中的每一个图片卡片都设置了固定的宽度和高度,并设置了一些阴影效果。
```html
.gallery-item{
box-shadow: 2px 2px 8px -1px #3498DB;
width: 300px;
height: 300px;
margin: 10px;
background: #000;
position: relative;
cursor: pointer;
overflow: hidden;
}
```
图片使用绝对定位,宽度和高度都等于卡片的宽度和高度,并设置了0.5秒的ease过渡动画效果。
.gallery-item-image{
```html
position: absolute;
width: 100%;
height: 100%;
background: lightblue;
z-index:20;
-webkit-transition:all .5s ease;
transition: all .5s ease;
bottom:0;
overflow: hidden;
}
```
当鼠标滑过卡片时,移动图片的bottom属性,使图片向上移动。
```html
.gallery-item:hover .gallery-item-image{
bottom: 80px;
}
```