- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我尝试在浏览器窗口中使用固定位置的可移动道场。不幸的是,每次我用鼠标移动 div 时,位置都设置为绝对。我该怎么做才能使 div 固定?
html:
<html>
<body>
<div id="moveMe" style="position:fixed;width:100px;height:100px;border:1px solid black;background-color:#00ff00;cursor:pointer;">bla</div>
<p>test<br>test<br>test<br>test<br>test<br>test<br>test<br>test<br>
test<br>test<br>test<br>test<br>test<br>test<br>test<br>test<br>
test<br>test<br>test<br>test<br>test<br>test<br>test<br>test<br>
test<br>test<br>test<br>test<br>test<br>test<br>test<br>test<br>
test<br>test<br>test<br>test<br>test<br>test<br>test<br>test<br>
</body>
</html>
脚本:
dojo.require("dojo.dnd.move");
dojo.ready(function(){
var pcm = new dojo.dnd.move.boxConstrainedMoveable(dojo.byId("moveMe"), {
box : dojo.window.getBox(),
within : true
});
});
测试链接: http://jsfiddle.net/zPVdX/
干杯,克拉特
最佳答案
position: fixed 和 position: absolute 是浏览器用来确定元素定位方式的两种完全相反的方法。
我首先建议阅读它们之间的差异:http://css-tricks.com/absolute-relative-fixed-positioining-how-do-they-differ/
希望现在您能理解为什么 Dojo draggable 需要将您的元素设置为绝对位置。这允许 Dojo 通过它的 top: 和 left: 属性直观地移动可拖动元素。
将此与静态定位进行比较,静态定位将尝试将您的元素锚定到相对于当前视口(viewport)的位置。
如果您添加更多关于您在视觉上尝试完成的内容的详细信息,可能会有另一种解决方案。
关于javascript - dojo.dnd.moveable,位置为 :fixed,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12905958/
我正在使用 Scriptaculous 使元素 (id="moveable1") 可拖动/可移动: new Draggable('moveable1'); 使用 javascript - 我怎样才能最
我尝试在浏览器窗口中使用固定位置的可移动道场。不幸的是,每次我用鼠标移动 div 时,位置都设置为绝对。我该怎么做才能使 div 固定? html: bla testtesttesttesttes
我正在使用 dojo/dnd/Moveable 来在页面上拖动 div,类似于下面的示例。 在用户拖动 div 时运行的事件 'move' 期间,我需要应用一些逻辑(在我的真实示例中,我需要检查一些鼠
当我通过应用 dojo.dnd.moveable 使 div 可移动时,它可以移动到视口(viewport)之外。我怎样才能避免这种情况? 最佳答案 使用 dojo.dnd.move.boxConst
我最近安装了 Visual Studio 2010 Professional RC 来试用它并测试在 VC++ 2010 中实现的几个 C++0x 功能。 我实例化了 std::unique_ptr
我正在使用 gmock 并模拟了一个函数 boost::beast::http::response_parser作为输出参数。功能签名看起来像: error_code readFromSocket(b
过去几个小时我一直在努力解决这个问题。我可以通过一个简单的 node.js 应用程序很好地使用react-moveable。当我尝试在 NEXTjs 应用程序中使用相同的模块时,它会抛出错误:Type
我是一名优秀的程序员,十分优秀!