我希望在文本上方创建一个透明的暗图像覆盖图像.在悬停时有一个很好的过渡.
.study1 { background-image: url("http://www.livingfengshui.ca/wp-content/uploads/2013/07/file7881255537584.jpg"); height: 300px; width: 400px; } .title { margin: 0 auto; width: 60%; display: block; font-size: 1.25em; color: #ccc; text-align: center; padding-top: 120px; }
<div class="study1"> <div class=""> <a class="title" href="#">View Case Study</a> </div> </div>
我想要的设计是这样的:
解决方法
.study1 { background-image: url("http://www.livingfengshui.ca/wp-content/uploads/2013/07/file7881255537584.jpg"); height: 300px; width: 400px; position:relative; z-index:1; } .study1:after{ content:""; position:absolute; left:0; right:0; top:0; bottom:0; margin:auto; width:100%; height:100%; background:rgba(0,0.5); z-index:-1; } .title { margin: 0 auto; width: 60%; display: block; font-size: 1.25em; color: #ccc; text-align: center; padding-top: 120px; } .transparent-dark { background: rgba(0,0.5); height:100%; }
<div class="study1"> <div class="transparent-dark"> <a class="title" href="#">View Case Study</a> </div> </div>
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。