HTML Element Style How to - Create round border for image with overflow hidden








Question

We would like to know how to create round border for image with overflow hidden.

Answer


<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
.teaser {<!--  ww w  .j  a  va  2  s .co  m-->
  -webkit-border-radius: 20px;
  -moz-border-radius: 20px;
  border-radius: 20px;
  overflow: hidden;
  display: inline-block;
}

img {
  vertical-align: bottom;
}
</style>
</head>
<body>
  <div class="teaser">
    <img src="http://www.java2s.com/style/download.png">
  </div>
</body>
</html>

The code above is rendered as follows: