LoginSignup
4
2

More than 3 years have passed since last update.

CSSで波を作ってみる

Posted at

CSSで波を作ってみる

揺らぐ円を描いたら、波も作ってみたくなった

ので!!

調べてみたところ、すでに記事があったので参考にさせていただきました。

理想形???(結果)

See the Pen Wave by YamaOK (@yamaok) on CodePen.

やったこと

基本的には参考記事の通りです。
工夫したところといえば、vueで可変にしたところでしょうか。

    const waves = new Vue({
        el:'#waveBack',
        data:{
            // 波の数を指定
            waveCount:28,
            // 波の動き/形を2通り指定
            features:[
                {radius:9,duration:8},
                {radius:10,duration:9},
            ],
        },
        methods: {
            // animationを動的に作成
            getCss:function(wave){
                let feature = this.features[wave % this.features.length]
                // 左から順に重ねるが、2つセットで等間隔に配置する
                let left = -10 + wave * 3 + wave%2 * 3
                return `left:${left}em;bottom:2em;border-radius:${feature.radius}em;animation-duration:${feature.duration}s`
            }
        },
    })
4
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
2