Warm tip: This article is reproduced from serverfault.com, please click

How to make a round mask over a image

发布于 2015-05-07 13:46:59

This is my take using css only, but the image is not centred, and also the image get bigger not the mask

jsfiddle Demo

I want to achieve the same affect in here

http://jackietrananh.com/portfolio.php

He is using an image http://jackietrananh.com/img/sprite-s82d3b02845.png but how this can happen with pure css or js?

and without

clip-path
Questioner
grape1
Viewed
0
David Calvin 2015-05-07 22:39:19

I would accomplish this as follows: HTML:

<div class="round">
   <img src="http://www.somebodymarketing.com/wp-content/uploads/2013/05/Stock-Dock-House.jpg"/>
</div>

CSS:

.round{
  width:10%;
  padding-top:10%;
  overflow:hidden;
  position:relative;
  border-radius:50%;
}
img{
  position:absolute;
  top:50%;
  left:50%;
  min-width:100%;
  height:100%;
  transform:translate(-50%,-50%);
  transition: 1s ease;
}
img:hover{
  height:110%;
}

Example: CodePen