【问题标题】:Draggable Containment Option Doesn't Limit Item's Right or Bottom Borders?可拖动的包含选项不限制项目的右边框或下边框?
【发布时间】:2012-12-21 15:30:15
【问题描述】:

我有一个可拖动的项目,我想将它包含在一个 div 类中。我有以下代码

HTML:

<div class = 'right'>
<div id = 'frame1'>
      <iframe id = 'iframe1' src = 'http://www.wsj.com'></iframe>
    </div>
</div>
​

CSS:

.right {
        position: absolute;
        width: 60%;
        height: 100%;
        left: 25%;
        top: 20%;           
        background-color: #006400;
       }

#frame1 {
              position: absolute;
              float: left;
              width: 45%; 
              height: 75%; 
              top: 10%;
              left: 2%;
              margin: 10px; 
              border-style: solid; 
              border-width: 10px;
         }    
#frame2 {
              position: absolute;
              float: right;
              width: 45%; 
              height: 75%; 
              top: 10%;
              right: 2%;
              margin: 10px; 
              border-style: solid; 
              border-width: 10px;
        }
#frame3 {
            position: absolute;
            float: center;
            width: 45%;
            height: 75%;
            top: 10%;
            left: 25.5%;
            margin: 10px;
            border-style: solid;
            border-width: 10px;
        }
#iframe1 {
          width: 181%; 
          height: 182%; 
          top: 50%;
          left: 50%;
          zoom: 1.00; 
          -moz-transform: scale(0.55); 
          -moz-transform-orgin: 0 0;
          -o-transform: scale(0.55); 
          -o-transform-origin: 0 0; 
          -webkit-transform: scale(0.55); 
          -webkit-transform-origin: 0 0;
         }

JavaScript:

$("#frame1, #frame2, #frame3").draggable({containment: ".right", stack: "div"});​​

可拖动项目在 div 类的左边框和上边框上的移动受到限制,但是对于我可以将对象向右或底部移动多远似乎没有限制。我需要在代码中进行哪些更改才能使 div 类的所有四个侧面都包含可拖动选项?

jsFiddle here

【问题讨论】:

    标签: javascript jquery css draggable


    【解决方案1】:

    是的,只需为您的 iframe 更新以下 css。我希望这将帮助您获得包含在 div 类的所有四个方面的可拖动选项。

    #iframe1 {
              position: absolute;
              width: 181%; 
              height: 182%;
              zoom: 1.00; 
              -moz-transform: scale(0.55); 
              -moz-transform-orgin: 0 0;
              -o-transform: scale(0.55); 
              -o-transform-origin: 0 0; 
              -webkit-transform: scale(0.55); 
              -webkit-transform-origin: 0 0;
             }
    

    这里我已经用答案更新了jsfiddle

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-12-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-11-27
      • 1970-01-01
      相关资源
      最近更新 更多