快速 CSS 悬停问题
詹姆斯在这里。我有一个简单的问题。我想添加类似的图像悬停效果,例如 http://themaxdavis.com ,但由于某种原因我不能很明白。当您将鼠标悬停在图片帖子 (.pic) 上时,我想在我的代码中添加一个不透明度为 0.5 的黑色叠加层,以淡入图像本身。另外,如果有人能帮助我找到一种方法,像马克斯·戴维斯一样将文本放入黑色覆盖层中,那就太棒了。这是 .pic 元素的代码。
.pic { position:relative; overflow: hidden; float: left;
{block:IndexPage}width:250px;{block:IndexPage}
{block:PermalinkPage}width:500px; margin-top: 39px; margin-bottom:
15px;{/block:PermalinkPage} {block:IndexPage}margin: 15px 15px 0px
0px;{/block:IndexPage} background-color: #FFF; z-index: 1;
{block:IndexPage}box-shadow: 0px 0px 8px rgba(0, 0, 0, 0.2);
-webkit-transition: box-shadow 0.3s ease-out;
-moz-transition: box-shadow 0.3s ease-out; transition: box-shadow 0.3s
ease-out;
-o-transition: box-shadow 0.3s ease-out;{block:IndexPage} }
我的网站网址是 http://-respawn.tumblr.com
PS 我正在出门的路上现在,所以我不会立即接受答案,但我会接受它们,并在回家后立即阅读它们。
James here. I have a quick question. I want to add a similar image hover affect like on http://themaxdavis.com , but for some reason I can't quite get it. I want to add to my code when you hover over the picture post (.pic), a black overlay with a 0.5 opacity to fade in over the image itself. Also, if anyone could help me figure out a way to put text inside that black overlay also like Max Davis, that would be AWESOME. Here is the code to the .pic element.
.pic { position:relative; overflow: hidden; float: left;
{block:IndexPage}width:250px;{block:IndexPage}
{block:PermalinkPage}width:500px; margin-top: 39px; margin-bottom:
15px;{/block:PermalinkPage} {block:IndexPage}margin: 15px 15px 0px
0px;{/block:IndexPage} background-color: #FFF; z-index: 1;
{block:IndexPage}box-shadow: 0px 0px 8px rgba(0, 0, 0, 0.2);
-webkit-transition: box-shadow 0.3s ease-out;
-moz-transition: box-shadow 0.3s ease-out; transition: box-shadow 0.3s
ease-out;
-o-transition: box-shadow 0.3s ease-out;{block:IndexPage} }
My website URL is http://-respawn.tumblr.com
PS I'm on my way out the door now, so I will not accept the answers right away, but I will accept them and read them all as soon as I get home.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
清理代码:
假设 .pic 将包含图片作为背景或将是 img 元素。
在 .pic 中创建一个空的 div 元素并为其指定此样式。
Cleaned up code:
Assuming that .pic will contain the picture as background or will be an img element.
Create an empty div element inside .pic and give it this style.