Page Widget How to - Create Convex Square








Question

We would like to know how to create Convex Square.

Answer


<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
.convex {<!-- ww w. ja v a2s.c  om-->
  height: 100px;
  width: 100px;
  margin: 100px;
  position: relative;
}

.convex.one {
  background-color: #f27011;
}

.convex.two {
  background-color: #5a7c87;
}

.convex:hover {
  background-color: #444;
}

.convex:after, .convex:before {
  background-color: inherit;
  content: '';
  position: absolute;
  z-index: -1;
}

.convex:after {
  border-radius: 10%/50%;
  bottom: 0;
  left: -10%;
  right: -10%;
  top: 0;
}

.convex:before {
  border-radius: 50%/10%;
  bottom: -10%;
  left: 0;
  right: 0;
  top: -10%;
}
</style>
</head>
<body>
  <div class="convex one"></div>
  <div class="convex two"></div>
</body>
</html>

The code above is rendered as follows: