CSS Property Value How to - Create bubble with :after :before








Question

We would like to know how to create bubble with :after :before.

Answer


<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
#mybox {<!--   ww  w . j  a  v a2 s . com-->
  width: 200px;
  height: 30px;
  border-style: solid;
  border-width: thin;
  border-color: #000066;
  border-radius: 4px;
  position: relative;
}

#mybox:after {
  content: "";
  border-color: #fff transparent transparent;
  border-style: solid;
  border-width: 9px;
  width: 0;
  height: 0;
  position: absolute;
  bottom: -18px;
  left: 21px
}

#mybox:before {
  content: "";
  border-color: #000066 transparent transparent;
  border-style: solid;
  border-width: 10px;
  width: 0;
  height: 0;
  position: absolute;
  bottom: -20px;
  left: 20px
}
</style>
</head>
<body>
  <div id="mybox">
    <center>This will be my tooltip</center>
  </div>
</body>
</html>

The code above is rendered as follows: