WAVEをCSSで動かす方法(波)
時々、うねうねと動く波(WAVE)を使っているWEBサイトを見かけますが、
CSSとSVG画像で実現できます。
SVG画像の内容はこちら(イラレなどで作り直してもOKです!)
↓
<svg xmlns="http://www.w3.org/2000/svg" width="1600" height="198">
<defs>
<linearGradient id="a" x1="50%" x2="50%" y1="-10.959%" y2="100%">
<stop stop-color="#ffffff" stop-opacity=".25" offset="0%"/>
<stop stop-color="#86D0F0" offset="100%"/>
</linearGradient>
</defs>
<path fill="url(#a)" fill-rule="evenodd" d="M.005 121C311 121 409.898-.25 811 0c400 0 500 121 789 121v77H0s.005-48 .005-77z" transform="matrix(-1 0 0 1 1600 0)"/>
</svg>
CSS部分はこちら
↓
.ocean {
height: 5%;
width:100%;
position:absolute;
bottom:0;
left:0;
position: absolute;
bottom:-50px;
}
.wave {
background: url(../svg/wave.svg) repeat-x;
position: absolute;
top: -198px;
width: 6400px;
height: 198px;
animation: wave 9s cubic-bezier( 0.36, 0.45, 0.63, 0.53) infinite;
transform: translate3d(0, 0, 0);
}
.wave:nth-of-type(2) {
top: -175px;
animation: wave 15s cubic-bezier( 0.36, 0.45, 0.63, 0.53) -.125s infinite, swell 10s ease -5.25s infinite;
opacity: 1;
}
@keyframes wave {
0% {
margin-left: 0;
}
100% {
margin-left: -1500px;
}
}
@keyframes swell {
0%, 100% {
transform: translate3d(0,-55px,0);
}
50% {
transform: translate3d(0,5px,0);
}
}
HTML部分はこちら!
↓
<!-- 動く波WAVE --> <div class="ocean"> <div class="wave"></div> <div class="wave"></div> </div> <!-- 動く波WAVE -->
参考サイト:https://codepen.io/tedmcdo/pen/PqxKXg
関連記事はこちら!
スポンサーリンク






