html - 灯箱悬停无法正常工作

标签 html css

你好,我制作了内联阻止列表,并希望让光线在图像周围悬停。它可以工作,但不是我想要的,因为光线大约占图像的一半,而且看起来不太好。也许有人可以告诉我我的 CSS 和 HTML 做错了什么,我怎样才能让那个灯箱环绕我的图像?

#planet {
   background-repeat: no-repeat;
   height: 350px;
   margin: 2px 2px 2px 2px;
   position: relative;
   width: 679px; 
}

.planet2 {
   display: inline-block;
   text-align:center;
   margin: 2px 2px 2px 2px;
}

.planet2 .img_img{
   width: 220px;
   text-align:center;
   height: 130px;
   -webkit-transition: width 2s; /* For Safari 3.1 to 6.0 */
   transition: width 2s;
}

.planet2:hover > .ahove{
  -webkit-border-radius: 10px;
  -moz-border-radius: 10px;
  border-radius: 10px;
  -webkit-box-shadow: 0px 0px 30px 0px rgba(0, 255, 0, 0.67);
  -moz-box-shadow:    0px 0px 30px 0px rgba(0, 255, 0, 0.67);
  box-shadow:         0px 0px 30px 0px rgba(0, 255, 0, 0.67);
}


.planet2 .img_description {
  background: rgba(0, 0, 0, 0.7);
  color: #fff;
  /* transition effect. not necessary */
  transition: opacity .2s, visibility .2s;
}
<div id="planet" style="background-image:url(../game/styles/images/port/rsz_senat_eo2.jpg)">
 
 <div class="planet2">
  <a class="ahove" href="">
   <img class="img_img" src="../game/styles/images/port/rsz_achiev_b.jpg"/> 
   <p class="img_description">Achievements</p>
  </a>
 </div> 
</div>

在这里,我的光悬停看起来不一样,它在图像的底部四处移动,但在我的页面中,它在左半边移动到图像中间,然后线到达图像底部的中间。

最佳答案

您必须将 .planet2:hover > .ahove 更改为 .planet2:hover > .ahove img,这样就可以了。

#planet {
  background-repeat: no-repeat;
  height: 350px;
  margin: 2px 2px 2px 2px;
  position: relative;
  width: 679px;

}



.planet2 {
  display: inline-block;
  text-align:center;
  margin: 2px 2px 2px 2px;
}

.planet2 .img_img{
  width: 220px;
  text-align:center;
  height: 130px;
  -webkit-transition: width 2s; /* For Safari 3.1 to 6.0 */
  transition: width 2s;

}


.planet2:hover > .ahove img{
  -webkit-border-radius: 10px;
  -moz-border-radius: 10px;
  border-radius: 10px;
  -webkit-box-shadow: 0px 0px 30px 0px rgba(0, 255, 0, 0.67);
  -moz-box-shadow:    0px 0px 30px 0px rgba(0, 255, 0, 0.67);
  box-shadow:         0px 0px 30px 0px rgba(0, 255, 0, 0.67);

}


.planet2 .img_description {
  background: rgba(0, 0, 0, 0.7);
  color: #fff;
  /* transition effect. not necessary */
  transition: opacity .2s, visibility .2s;
}
<div id="planet" style="background-image:url(../game/styles/images/port/rsz_senat_eo2.jpg)">

  <div class="planet2">
    <a class="ahove" href="">
      <img class="img_img" src="../game/styles/images/port/rsz_achiev_b.jpg"/> 
      <p class="img_description">Achievements</p>
    </a>
  </div>

</div>

关于html - 灯箱悬停无法正常工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49586220/

相关文章:

javascript - 页面展开时如何让页面自动滚动? (可折叠内容)

javascript - 动态设置div的高度

jquery - 动画切换滑动菜单

CSS3 变换一个元素而不是它的后代

css - 我不希望我的图像在应用样式后返回

javascript - 如何使用 Google Maps Javascript API v3 绘制特定的复杂形状

javascript - 通过 javascript 更改边距顶部在 Chrome 中不起作用

css - 将响应式 SVG 图像 mask 应用于 HTML5 视频

php - html php 元字符集 UTF-8 不工作?

android - 如何为 iOS、Android、BBerry、Symbian 创建 Web 应用程序