具有悬停效果的响应性图像点 [英] Responsive image spots with hover effects

查看:25
本文介绍了具有悬停效果的响应性图像点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在这里有一个相当大的挑战!

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

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

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

我们将非常感谢您的帮助

推荐答案

这可能是您的起点。只要你知道你的图像大小,在你的例子中是914x913...你只需要使用position: absolute;和从左、右、上、下的像素,这取决于你想要它的位置...这只是一个测量的问题(也是一个小的试错)。请看代码片段……我为您创建了两个"热点"以供您开始使用(用红色圈出)。当你将鼠标悬停在那里时,出现的方框就在那里,你可以玩定位,显然比普通的方框更好地设计了它的样式。顺便说一句,<span></span>只是为了让‘热点’分开,否则光晕会对你的背景图像产生奇怪的影响。哦,如果您计划让它支持较小的视区,则必须为每个视区添加媒体查询,以调整每个热点的位置。

数据-lang="js"数据-隐藏="假"数据-控制台="真"数据-巴贝尔="假">
<!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>

这篇关于具有悬停效果的响应性图像点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆