有時候制作小程序需要一點動態的效果。 話不多說直接上圖看效果。
話說實現方式很簡單。
首先准備一張背景圖。
然后准備一張波浪圖:
下載:點我下載
vue的代碼如下:
<template>
<div>
<section class="sec-nav">
<navigationBar :title="videoTitle" :titleColor="'black'"></navigationBar>
</section>
<div class="content">
<div class="about-bg">
<image src="https://image.weilanwl.com/gif/wave.gif" mode="scaleToFill" class="about-img"></image>
</div>
</div>
</div>
</template>
<script>
接着CSS代碼如下:
<style lang="scss">
.content {
background-color:#f8f8f9;
width: 100vw;
height: 200vh;
box-sizing: border-box;
display: flex;
padding-top: 0rpx;
flex-direction: column;
justify-content: flex-start;
.about-bg{
background-image: url(http://www.jingsoftware.com:3316/chen_xcy/img/context/aboutus.jpg);
width:100vw;
height:300rpx;
background-size: cover;
display: flex;
justify-content: center;
padding-top: 40rpx;
overflow: hidden;
position: relative;
flex-direction: column;
align-items: center;
color: #fff;
font-weight: 300;
text-shadow: 0 0 3px rgba(0, 0, 0, 0.3);
.about-img {
position: absolute;
width: 100%;
bottom: 0px;
left: 0;
z-index: 99;
mix-blend-mode: screen;
height: 100rpx;
}
}
}
</style>
這里的關鍵就是這段話:
mix-blend-mode: screen;
這種技巧可以套用任意一張背景圖用來做波浪圖。