今天想要分享的是這個,
記得我當時看到這個效果的時候覺得真的是炫炮過頭了,
馬上整個影片看完做練習,
做一做還邊想可以用什麼不一樣的方式做,
結果我老師建議我可以用 box-shadow
做,
想了半天覺得:「恩!我懶得去計算,還是就用 ::before
、::after
吧!」
效果
HTML
<div class="container">
<div class="item-group">
<div class="item"><img src="https://picsum.photos/300/500/?random=1"></div>
<div class="item"><img src="https://picsum.photos/300/500/?random=2"></div>
<div class="item"><img src="https://picsum.photos/300/500/?random=3"></div>
<div class="item"><img src="https://picsum.photos/300/500/?random=4"></div>
</div>
</div>
CSS
* {
padding: 0;
margin: 0;
list-style: none;
}
img {
width: 100%;
vertical-align: middle;
}
.container {
width: 960px;
margin: auto;
line-height: 100vh;
}
.item-group {
display: inline-block;
vertical-align: middle;
}
.item-group::after {
content: '';
display: block;
height: 0;
clear: both;
}
.item {
width: 210px;
line-height: 1;
margin: 0 15px;
float: left;
position: relative;
}
.item::before,
.item::after {
content: '';
width: 50%;
height: 0%;
background-color: #fff;
position: absolute;
transition: .5s;
}
.item::before {
left: 0;
top: 0;
}
.item::after {
right: 0;
bottom: 0;
}
.item-group:hover .item::before,
.item-group:hover .item::after {
height: 100%;
}
.item-group .item:hover::before,
.item-group .item:hover::after {
height: 0;
}
今天就先到這裡啦~
我們明天見。