Help us understand the problem. What is going on with this article?

CSSで水中を表現する

More than 3 years have passed since last update.

water.png

html

<div id="water">
  <div class="surface"></div>
  <div class="bubble1"></div>
  <div class="bubble2"></div>
</div>

CSS

*{
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html,body{
  height: 100%;
}

#water{
  width: 100%;
  height: 100%;
  background: #023EE4;
}

/* 水面 */
.surface{
  width: 100%;
  transform: rotate(-5deg);
  box-shadow: 0 0 100px 200px #55BEFC;

  /* 水の流れを表現 */
  animation: flowing 20s ease-in-out infinite alternate;
}

.bubble1{
  position: absolute;
  bottom: 0;
  left: 500px;
  border-radius: 100%;
  width: 15px;
  height: 15px;
  box-shadow: 
     0    -30px 0 1px rgba(255,255,255,0.2),
     10px  10px 0 1px rgba(255,255,255,0.2),
     10px -60px 0 1px rgba(255,255,255,0.2),
     20px -70px 0 1px rgba(255,255,255,0.2),
     30px -80px 0 1px rgba(255,255,255,0.2),
     40px -70px 0 1px rgba(255,255,255,0.2),
    -10px -90px 0 1px rgba(255,255,255,0.2),
    -20px -90px 0 1px rgba(255,255,255,0.2),
    -30px -30px 0 1px rgba(255,255,255,0.2);

  /* 気泡の動きを表現  */
  animation: _float 10s ease-out infinite;
}

.bubble2{
  position: absolute;
  bottom: 0;
  right: 100px;
  border-radius: 100%;
  width: 30px;
  height: 30px;
  box-shadow: 
     0    -30px 0 1px rgba(255,255,255,0.2),
     10px -60px 0 1px rgba(255,255,255,0.2),
     10px  10px 0 1px rgba(255,255,255,0.2),
     10px  20px 0 1px rgba(255,255,255,0.2),
     20px -70px 0 1px rgba(255,255,255,0.2),
     30px -70px 0 1px rgba(255,255,255,0.2),
     30px -80px 0 1px rgba(255,255,255,0.2),
     30px -90px 0 1px rgba(255,255,255,0.2),
     40px -70px 0 1px rgba(255,255,255,0.2),
     40px 150px 0 1px rgba(255,255,255,0.2),
     90px -20px 0 1px rgba(255,255,255,0.2),
    -10px -90px 0 1px rgba(255,255,255,0.2),
    -20px -90px 0 1px rgba(255,255,255,0.2),
    -30px -30px 0 1px rgba(255,255,255,0.2),
    -50px  10px 0 1px rgba(255,255,255,0.2),
   -100px -90px 0 1px rgba(255,255,255,0.2);

  /* 気泡の動きを表現 */
  animation: right_float 10s ease-out 2.5s infinite;
}

@keyframes flowing{
  from{
    transform: rotate(-5deg);
  }

  to{
    transform: rotate(3deg);
  }
}


@keyframes _float{
  from{
    bottom: 0;
  }

  to{
    bottom: 110%;
  }
}

@keyframes right_float{
  from{
    bottom: 0;
    right: 100px;
  }

  to{
    bottom: 120%;
    right: 120px;
  }
}

気泡(bubble)はbox-shadowで円(の影)を複製して作っています。

スクリーンショット 2015-08-09 13.07.07.png

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした