45

I want to create an animation with css that simulate a wave movement.
I need to change a line-or div- to a curve for this...
The CSS rules that I'm familiar to, make the entire div to semicircular or change element border.
For example: border-radius, or perspective or border-top-radius...
This image show you what I want: curve

Is this possible? If so, how can it be done?

starball
  • 20,030
  • 7
  • 43
  • 238
Kiyarash
  • 2,437
  • 7
  • 32
  • 61

2 Answers2

92

You could use an asymmetrical border to make curves with CSS.

border-radius: 50%/100px 100px 0 0;

VIEW DEMO

.box {
  width: 500px; 
  height: 100px;  
  border: solid 5px #000;
  border-color: #000 transparent transparent transparent;
  border-radius: 50%/100px 100px 0 0;
}
<div class="box"></div>
ifconfig
  • 6,242
  • 7
  • 41
  • 65
Elad Shechter
  • 3,885
  • 1
  • 22
  • 22
15

@Navaneeth and @Antfish, no need to transform you can do like this also because in above solution only top border is visible so for inside curve you can use bottom border.

.box {
  width: 500px;
  height: 100px;
  border: solid 5px #000;
  border-color: transparent transparent #000 transparent;
  border-radius: 0 0 240px 50%/60px;
}
<div class="box"></div>
mplungjan
  • 169,008
  • 28
  • 173
  • 236