0
A
回答
1
通過在:hover
上創建線性漸變透明白色透明和移動背景向前/向後實現的當前效果。
這裏的解決方案將圖像放置在此動畫下。但請記住,無盡的動畫可能非常分散注意力和惱人的爲你的用戶
.wrapper {
position: relative;
width: 350px;
height: 150px;
/*border: 2px solid #444;*/
border-radius: 10px;
overflow: hidden;
}
img {
position: relative;
z-index: 0;
width: 100%;
}
.gradient {
transition: background-position .5s;
background-size: 200% auto;
box-shadow: 0 0 20px #eee;
font: 0;
position: absolute;
z-index: 1;
left: 0;
top: 0;
right: 0;
bottom: 0;
}
.gradient {
background-image: linear-gradient(to top, transparent 0%, white 51%, transparent 100%);
background-position: center bottom;
}
.gradient:hover {
background-position: center top;
}
.gradient.animated {
animation: gradient 2s infinite;
}
@keyframes gradient {
0% {
background-position: center bottom;
}
50% {
background-position: center top;
}
100% {
background-position: center bottom;
}
}
<div class='wrapper'>
<div href='#' class='gradient'></div>
<img src='http://lorempixel.com/350/150/sports/' />
</div>
<div class='wrapper'>
<div href='#' class='gradient animated'></div>
<img src='http://lorempixel.com/350/150/sports/' />
</div>
,並更好地理解
你可以找到更多的文章下面
simplier例子
.gradiented {
transition: background-position .5s;
background-size: 200% auto;
box-shadow: 0 0 20px #eee;
border-radius: 10px;
width: 200px;
height: 200px;
}
.gradiented {
background-image: linear-gradient(to top, #283048 0%, #859398 51%, #283048 100%);
background-position: center bottom;
}
.gradiented:hover {
background-position: center top;
}
<div href='#' class='gradiented'></div>
+0
u能告訴我重複我怎樣才能讓動漫嬉戲自動(無鼠標移到圖片)? –
+1
@AliH編輯,看第一段 – godblessstrawberry
+0
@AliH yw,請記住無盡的動畫可能會讓你的用戶非常分心和煩人 – godblessstrawberry
相關問題
- 1. 使用線性梯度(純CSS)實現動畫蹺蹺板效果
- 2. CSS - 錯誤的線性梯度
- 3. 重複線性梯度頁
- 4. HTML帆布梯度動畫
- 5. css梯度給滾動條
- 6. css:什麼是鉻的-moz線性梯度的等值線
- 7. 使用手動梯度計算的線性迴歸
- 8. CSS - 無限的動畫(移動到右裝載梯度)閃爍
- 9. 從梯形到右梯形的動畫變換充滿梯度
- 10. 梯度HTML5畫布
- 11. 內聯CSS到角2 - 線性梯度到背景圖像
- 12. 的jQuery/CSS創建線性梯度僅具有一個顏色
- 13. CSS梯度劣質
- 14. CSS瘋狂梯度
- 15. jQuery的CSS梯度
- 16. 使用CSS梯度來完成淡出
- 17. CSS3線性梯度純色大小
- 18. 改變梯度hr的線性值
- 19. 火狐的動畫/梯度CSS3支持
- 20. iOS梯度動畫與uiscrollview分頁
- 21. Quartz2D和梯度線
- 22. 使用CSS或CSS3動畫的線性擦除文本效果
- 23. 線性漸變相當於MOZ線性梯度
- 24. 使用CSS動畫動畫div高度時出現問題
- 25. 計算css梯度差
- 26. CSS動畫屬性保持動畫後
- 27. 梯度上線圖(Highcharts)
- 28. 從梯度重構曲線
- 29. CSS寬度動畫方向
- 30. 使用CSS變量與rgba的梯度透明度
@Paulie_D它沒有提到的問題 – godblessstrawberry