Ter*_*nce 1 html javascript css jquery
我的网站中有一个功能,当用户将鼠标悬停在他/她的显示图片上时,会出现一个叠加层。
但遗憾的是,我希望覆盖层不要覆盖整张照片。我希望它只是圆的一半。
我曾尝试研究解决方案,但似乎找不到任何解决方案。
这是我希望它看起来像的图像。
提前致谢。
如果您能指导我如何实现这种效果,我将不胜感激。
诀窍是,添加overflow:hidden到容器(圆)并使覆盖层的高度为圆的一半。这是一个示例代码:
#circle{
width:200px;
height:200px;
border-radius:50%;
background-color:#0098dd;
position:relative;
overflow:hidden;
}
#overlay{
display:none;
position:absolute;
bottom:0;
text-align:center;
width:200px;
height:100px; /* Half of the container */
line-height:100px;
background-color:rgba(255,255,255,0.5);
}
#circle:hover #overlay{
display:block;
}Run Code Online (Sandbox Code Playgroud)
<div id="circle">
<div id="overlay">
Test
</div>
</div>Run Code Online (Sandbox Code Playgroud)