怎么在DIV图片上加个DIV,并带有按钮链接呢?

怎么在DIV图片上加个DIV,并带有按钮链接呢?如同所示,哪位大神给个完整代码谢谢!
图片描述

阅读 4.5k
4 个回答

给你写了一个简单的hover效果
http://jsrun.net/TQYKp

html

<div class='box'>
  <div class='image'>
    <img src='http://imgsrc.baidu.com/imgad/pic/item/730e0cf3d7ca7bcbd0a1ac09b4096b63f624a83a.jpg'
    width='100%'>
  </div>
  <div class='mask'>
    <a class='link' href='#'>
      查看更多
    </a>
  </div>
</div>

css

.mask {
  background: #ff00a5;
  width: 300px;
  height: 200px;
  position: absolute;
  top: 0;
  z-index: 99;
  display: none
}

.image {
  width: 300px;
  height: 200px;
}

.box {
  position: relative;
  width: 300px;
}

.box:hover .mask {
  display: block;
}

.box:hover .link {
  width: 120px;
  height: 40px;
  display: block;
  background: #FFF;
  line-height: 40px;
  text-align: center;
  margin: 80px auto;
  color: #ff00a5
}

编程最重要的是思想,代码自己实现。
基本思路就是使用position来解决这个问题。

加个鼠标移入移除事件,img上放个div移除时透明,

用display就可以实现啊。。移入移出设置下就好了啊

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题