【问题标题】:Responsive image spots with hover effects具有悬停效果的响应式图像点
【发布时间】:2021-11-24 08:41:46
【问题描述】:

我在这里遇到了很大的挑战!

设计师发送的这个光照树有一些光点,在鼠标悬停时应该显示指向网站页面的菜单链接。不仅如此,在悬停时,应该激活一个覆盖层来改变整个网站的色调(某种黑色覆盖层,降低了不透明度)

我面临的问题是我真的不知道从哪里开始!我想实现某种图像映射,但后来我不知道如何设置它的响应式,我真的很难想出解决这个设计挑战的解决方案。

正如您在屏幕截图中看到的那样,灯光树必须作为标题背景,并且光点应位于树的某些特定部分。

非常感谢您的帮助

【问题讨论】:

  • 有代码吗?没有就不可能知道。

标签: html css responsive-design responsive responsive-images


【解决方案1】:

这可能是您的起点。只要您知道图像大小,在您的情况下是 914x913...您可以使用position: absolute; 和左、右、上、下的像素,具体取决于您想要的位置...这只是测量的问题(也有一些试验和错误)。请参阅代码 sn-p...我创建了两个“热点”供您开始使用(以红色标出)。而且翻车时出现的盒子就在那里,你可以玩弄定位并且明显比普通盒子更好地设计它。顺便说一句,<span></span> 只是为了让“热点”分开,否则发光会对你的背景图像产生奇怪的影响。哦,如果你打算让这个支持更小的视口,你将不得不为每个视口添加媒体查询以调整每个热点的位置。

<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8" />
  <meta name="viewport"
    content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, shrink-to-fit=no" />
  <title>Test</title>

  <style>
    body {
      font-family: sans-serif;
      color: white;
    }

    .container {
      background-image: url('https://i.stack.imgur.com/lzxlC.png');
      background-size: contain;
      background-repeat: no-repeat;
      background-position: center center;
      display: flex;
      width: 914px;
      height: 913px;
      margin: 0 auto;
      position: relative;

    }


    /* SPOT 1  */
    .spot-1 {
      position: absolute;
      left: 323px;
      top: 148px;
    }

    .spot-1 span {
      border: 3px solid #FF6F6F;
      border-radius: 50px;
      height: 30px;
      width: 30px;
      display: flex;
      align-self: center;
    }

    .spot-1:hover span {
      box-shadow: 0 0 60px 30px #fff, 0 0 140px 90px #009EAB;
      animation: fadeIn 1s linear;
    }

    .box-1 {
      display: none;
    }

    .spot-1:hover .box-1 {
      display: flex;
      width: 80px;
      height: 25px;
      background: black;
      color: white;
      position: relative;
      left: 50px;
      padding: 12px;
      font-size: 10px;
    }




    /* SPOT 2  */
    .spot-2 {
      position: absolute;
      left: 515px;
      top: 163px;
    }

    .spot-2 span {
      border: 3px solid #FF3F3F;
      border-radius: 50px;
      height: 30px;
      width: 30px;
      display: flex;
      align-self: center;
    }

    .spot-2:hover span {
      box-shadow: 0 0 60px 30px #fff, 0 0 140px 90px #009EAB;
      animation: fadeIn 1s linear;
    }

    .box-2 {
      display: none;
    }

    .spot-2:hover .box-2 {
      display: flex;
      width: 80px;
      height: 25px;
      background: black;
      color: white;
      position: relative;
      left: 50px;
      padding: 12px;
      font-size: 10px;
    }


    @keyframes fadeIn {
      from {
        opacity: 0;
      }

      to {
        opacity: 1;
      }
    }
  </style>
</head>

<body>
  <div class="container">
    <div class="spot-1"><span></span>
      <div class="box-1">HOWDY!</div>
    </div>

    <div class="spot-2"><span></span>
      <div class="box-2">HI</div>
    </div>

  </div>

</body>

</html>

【讨论】:

    猜你喜欢
    • 2019-05-03
    • 1970-01-01
    • 1970-01-01
    • 2015-04-25
    • 2017-03-30
    • 1970-01-01
    • 2020-01-23
    • 1970-01-01
    • 2014-05-25
    相关资源
    最近更新 更多