我們用的第一個濾鏡是sepia(),他會給圖片增加一整降飽和度的橙色染色效果
原圖
添加sepia濾鏡的效果
img{ width:100%; transition: .5s filter; filter:sepia(2); } img:hover{ filter:none; }
給色度添加飽和度可以用saturate()
filter: saturate(4);
兩個同時添加的效果
filter:sepia(2) saturate(4);
如果不希望把圖片調成橙黃色調也可以添加hue-rotate濾鏡,變成稍深的亮粉色,大約295度
filter:sepia(1) saturate(4) hue-rotate(295deg);
還有一種毛玻璃的效果如下
html
<div class="box"> <p class='p'> An international forum for the world's major bay areas launched a new cooperation platform over the weekend to exchange resources and development ideas, with bay areas in China and the United States also standing to benefit. </p> </div>
css
.box { margin: 0 auto; width: 500px; height: 300px; color: #fff; background: url('../assets/pic.jpg') 0 / cover; display: flex; justify-content: center; align-items: center; } .p{ position:relative; padding: 15px; background:hsla(0 ,0% ,100%,.3); width: 350px; font-size:1.2em; overflow:hidden; z-index: 1; } .p::before{ content:''; z-index:-1; position:absolute; top:0;left:0;right:0;bottom:0; filter:blur(20px); margin:-10px; background: url('../assets/pic.jpg') 0 / cover; }
效果圖