RError.com

RError.com Logo RError.com Logo

RError.com Navigation

  • 主页

Mobile menu

Close
  • 主页
  • 系统&网络
    • 热门问题
    • 最新问题
    • 标签
  • Ubuntu
    • 热门问题
    • 最新问题
    • 标签
  • 帮助
主页 / 问题 / 907032
Accepted
Anton Brock
Anton Brock
Asked:2020-11-16 00:23:04 +0000 UTC2020-11-16 00:23:04 +0000 UTC 2020-11-16 00:23:04 +0000 UTC

当您单击图像时,它应该以更大的尺寸浮动。一切都很好,但这是你如何将它移到中心,右边缘的一部分是灰色的

  • 772

当您单击图像时,它应该以更大的尺寸浮动。一切都很好,但这是将它移到中心的方法,右边缘的一部分是灰色的。

也许我是盲人,但我根本看不到问题所在。没有颜色变化,没有任何帮助,它只是被裁剪了,就是这样。

jQuery v3.3.1

代码,即脚本及其样式不是我的。我自己对此很陌生。所有与问题(代码)相关的内容都已附上。+ 屏幕

UPD:使用“poke”方法,出于某种原因,我决定在 property.popup_bg中,即它width 100%不是 100%。一输入150%,整个背景变暗,一切正常。同时,如果这个属性不存在,则无法关闭扩展图像。(很可能是脚本的原因)

如果你能告诉我原因,我会很高兴。:)

问题示例

$(document).ready(function() {
  $(".image").click(function() {
    var img = $(this);
    var src = img.attr('src');
    $("body").append("<div class='popup'>" +
      "<div class='popup_bg'></div>" +
      "<img src='" + src + "' class='popup_img' />" +
      "</div>");
    $(".popup").fadeIn(800);
    $(".popup_bg").click(function() {
      $(".popup").fadeOut(800);
      setTimeout(function() {
        $(".popup").remove();
      }, 800);
    });
  });
});
.image {
  /* margin:30px;  */
  /* float:left; */
  cursor: pointer;
  max-height: 300px;
}

.popup_img {
  position: fixed;
  margin: 0 auto;
  z-index: 2;
  max-height: 94%;
  max-width: 94%;
  margin-top: 25px;
  pointer-events: none;
}

.popup {
  position: fixed;
  height: 100%;
  width: 100%;
  top: 0;
  right: 300px;
  display: none;
  text-align: center;
}

.popup_bg {
  background: rgba(0, 0, 0, 0.699);
  position: fixed;
  z-index: 1;
  height: 100%;
  width: 100%;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<section class="b3">
  <div class="in3">
    <div class="content3">
      <h2>Your thoughts</h2>
      <div class="audio1">
        <div class="cover1">
          <img src="http://via.placeholder.com/250x250/ff00ff/000000" class="image" width="280px" height="280px" style="margin-bottom: 5px">
          <p class="nameCover1">Citizen — Yellow Love</p>
        </div>
        <audio src="6666.mp3" controls>Citizen — Yellow Love</audio>
      </div>
    </div>
  </div>
</section>

html
  • 1 1 个回答
  • 10 Views

1 个回答

  • Voted
  1. Best Answer
    Air
    2020-11-16T02:28:09Z2020-11-16T02:28:09Z

    我希望我理解正确

    $(document).ready(function() {
      $(".image").click(function() {
        var img = $(this);
        var src = img.attr('src');
        $("body").append("<div class='popup'>" +
          "<div class='popup_bg'></div>" +
          "<img src='" + src + "' class='popup_img' />" +
          "</div>");
        $(".popup").fadeIn(800);
        $(".popup_bg").click(function() {
          $(".popup").fadeOut(800);
          setTimeout(function() {
            $(".popup").remove();
          }, 800);
        });
      });
    });
    * {
      margin: 0;
      padding: 0;
    }
    
    html,
    body {
      width: 100%;
      height: 100%;
    }
    
    .image {
      cursor: pointer;
      max-height: 300px;
    }
    
    .popup {
      position: fixed;
      top: 0;
      right: 0;
      left: 0;
      bottom: 0;
      display: none;
      text-align: center;
    }
    
    .popup_bg {
      background: rgba(0, 0, 0, 0.699);
      position: absolute;
      z-index: 1;
      height: 100%;
      width: 100%;
    }
    
    .popup_img {
      position: absolute;
      left: 50%;
      top: 50%;
      margin: 0 auto;
      z-index: 2;
      pointer-events: none;
      transform: translate(-50%, -50%);
    }
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
    <section class="b3">
      <div class="in3">
        <div class="content3">
          <h2>Your thoughts</h2>
          <div class="audio1">
            <div class="cover1">
              <img src="http://via.placeholder.com/250x250/ff00ff/000000" class="image" width="280px" height="280px" style="margin-bottom: 5px">
              <p class="nameCover1">Citizen — Yellow Love</p>
            </div>
            <audio src="6666.mp3" controls>Citizen — Yellow Love</audio>
          </div>
        </div>
      </div>
    </section>

    • 1

相关问题

Sidebar

Stats

  • 问题 10021
  • Answers 30001
  • 最佳答案 8000
  • 用户 6900
  • 常问
  • 回答
  • Marko Smith

    是否可以在 C++ 中继承类 <---> 结构?

    • 2 个回答
  • Marko Smith

    这种神经网络架构适合文本分类吗?

    • 1 个回答
  • Marko Smith

    为什么分配的工作方式不同?

    • 3 个回答
  • Marko Smith

    控制台中的光标坐标

    • 1 个回答
  • Marko Smith

    如何在 C++ 中删除类的实例?

    • 4 个回答
  • Marko Smith

    点是否属于线段的问题

    • 2 个回答
  • Marko Smith

    json结构错误

    • 1 个回答
  • Marko Smith

    ServiceWorker 中的“获取”事件

    • 1 个回答
  • Marko Smith

    c ++控制台应用程序exe文件[重复]

    • 1 个回答
  • Marko Smith

    按多列从sql表中选择

    • 1 个回答
  • Martin Hope
    Alexandr_TT 圣诞树动画 2020-12-23 00:38:08 +0000 UTC
  • Martin Hope
    Suvitruf - Andrei Apanasik 什么是空? 2020-08-21 01:48:09 +0000 UTC
  • Martin Hope
    Air 究竟是什么标识了网站访问者? 2020-11-03 15:49:20 +0000 UTC
  • Martin Hope
    Qwertiy 号码显示 9223372036854775807 2020-07-11 18:16:49 +0000 UTC
  • Martin Hope
    user216109 如何为黑客设下陷阱,或充分击退攻击? 2020-05-10 02:22:52 +0000 UTC
  • Martin Hope
    Qwertiy 并变成3个无穷大 2020-11-06 07:15:57 +0000 UTC
  • Martin Hope
    koks_rs 什么是样板代码? 2020-10-27 15:43:19 +0000 UTC
  • Martin Hope
    Sirop4ik 向 git 提交发布的正确方法是什么? 2020-10-05 00:02:00 +0000 UTC
  • Martin Hope
    faoxis 为什么在这么多示例中函数都称为 foo? 2020-08-15 04:42:49 +0000 UTC
  • Martin Hope
    Pavel Mayorov 如何从事件或回调函数中返回值?或者至少等他们完成。 2020-08-11 16:49:28 +0000 UTC

热门标签

javascript python java php c# c++ html android jquery mysql

Explore

  • 主页
  • 问题
    • 热门问题
    • 最新问题
  • 标签
  • 帮助

Footer

RError.com

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

帮助

© 2023 RError.com All Rights Reserve   沪ICP备12040472号-5