//插入虚线框
var dashedElement = document.createElement("div");
dashedElement.style.cssText = dragDiv.style.cssText;
dashedElement.style.border = " dashed 2px #aaa ";
dashedElement.style.marginBottom = "6px";
dashedElement.style.width = dragDiv.offsetWidth - 2 * parseInt(dashedElement.style.borderWidth) + "px"; //减去boderWidth使虚线框大小保持与dragDiv一致
dashedElement.style.height = dragDiv.offsetHeight - 2 * parseInt(dashedElement.style.borderWidth) + "px"; //加上px 保证FF正确
dashedElement.style.position = "relative";
if (dragDiv.nextSibling) {
dragDiv.parentNode.insertBefore(dashedElement, dragDiv.nextSibling);
}
else {
dragDiv.parentNode.appendChild(dashedElement);
}
//拖动时变为absolute
dragDiv.style.width = dragDiv.offsetWidth + "px";
dragDiv.style.position = "absolute";
JS仿iGoogle自定义首页模块拖拽特效的方法(4)
内容版权声明:除非注明,否则皆为本站原创文章。