【问题标题】:How can I drag the iframe with header along with minimize and maximize options如何拖动带有标题的 iframe 以及最小化和最大化选项
【发布时间】:2018-10-30 06:07:27
【问题描述】:

我有一个带有标题“聊天”的 iframe 如何拖动带有标题的 iframe 以及最小化和最大化选项,或者如何拖动整个 iframe 而不是边框​​。

【问题讨论】:

  • 请向我们展示您的代码

标签: javascript html iframe drag


【解决方案1】:

jquery 的resizable()draggable() 将帮助您这样做。

希望this 的帖子可能对您有所帮助。

$(function() {
  "use strict";
  $(".framewrap").resizable().draggable();
  $(".framewrap .actionIcon").on("click", function() {
    $(this).closest(".framewrap").toggleClass("min");
  });
});
.body_padding {
  padding: 16px;
}

.framewrap {
  padding-right: 10px;
  padding-left: 10px;
  padding-bottom: 28px;
  background-color: #121101;
  width: 512px;
  height: 90px;
  -webkit-box-shadow: 2px 2px 16px -2px;
  box-shadow: 2px 2px 16px -2px;
  border-radius: 12px;
  position: absolute;
}

.framewrap span {
  color: #FFFFFF;
  font-size: small;
  font-style: normal;
  font-weight: 100;
}

.framewrap .actionIcon {
  display: inline-block;
  float: right;
  height: 18px;
  width: 18px;
  background-image: url(http://findicons.com/files/icons/2711/free_icons_for_windows8_metro/128/minimize_window.png);
  background-size: cover;
  background-position: center center;
  cursor: pointer;
}

.framewrap.min {
  height: 90px !important;
  width: 256px !important;
}

.framewrap.min .actionIcon {
  background-image: url(http://findicons.com/files/icons/2711/free_icons_for_windows8_metro/128/maximize_window.png);
}

.frame {
  width: 100%;
  height: 100%;
  background-color: #fff;
}
<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />
<div>
  <div class="framewrap">
    <span>Chat</span>
    <span class="actionIcon"></span>
    <iframe class="frame" src=""></iframe>
  </div>
</div>

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>

【讨论】:

  • 非常感谢,它对我帮助很大,但是我们如何才能拖动整个 iframe 而不是边框​​。
  • @Mounika 如果你看到 html 代码,带有类 framewrapdiv 包含 iframe,已应用于 jquery 中的 draggable() 方法sn-p,这意味着我们已经对整个iframe 应用了拖动。仍然不清楚,请与我们分享您的代码。
  • 好的,我现在明白了,它对我来说工作正常。非常感谢。
猜你喜欢
  • 2013-02-05
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-04-11
  • 1970-01-01
相关资源
最近更新 更多