克隆人职业添加无效
我有一个克隆函数,可以在双击时克隆对象。我还向这些克隆添加了 .addclass('Copy') 。但是,css 属性未正确应用。
假设我有一个 Block1。我有一个 Block1、Block2 的副本,在我的 html 文档中提供。 Block2 具有 .Copy 类,并且它可以正确应用。 (.copy 将重复项向左移动一定量。)这些自动生成的克隆具有该类,但该类的 margin 属性不受尊重。 .Copy 的左边距:-100px。克隆体显然没有移到一边这么多,而是一个奇怪的量,比如我设置的 82%。我在 html 中使用 .Copy 类手动提供的重复项偏离了 100px。
$(document).ready(function(){
$("img:not('.Copy, .Show_Card')").live('dblclick', function(){
var limit = $(this).parent().size();
if (limit < 4) {
var $clone = $(this).clone(true).addClass('Copy');
$(this).parent().find('.DCT_Card:last').before($clone);
}
});
});
这些 img 克隆确实设置了边框,我认为这可能导致了一些问题。所以我删除了边框属性并修复了奇数间距。那么有没有办法中继CSS效果呢?
I have a clone function that clones an object on doubleclick. I also have a .addclass('Copy') added to these clones. However, the css property isn't being applied properly.
Consider that i have a Block1. I have a duplicate of Block1, Block2, supplied in my html document. Block2 has the class .Copy, and it applies properly. (.copy moves the duplicate to the left by a certain amount.) These automatically generated clones have the class, but the margin property of the class isn't being respected. .Copy has a margin-left: -100px. The clones are visibly not moved to the side by this much, but rather an odd amount like 82% of whatever i set. The duplicates that i provided manually in the html with the .Copy class, are off to the side by 100px.
$(document).ready(function(){
$("img:not('.Copy, .Show_Card')").live('dblclick', function(){
var limit = $(this).parent().size();
if (limit < 4) {
var $clone = $(this).clone(true).addClass('Copy');
$(this).parent().find('.DCT_Card:last').before($clone);
}
});
});
These img clones do have a border set to them, which i thought might have been causing some issues. So i removed the border property and that fixed the odd spacing. So is there a way to relayer the css effects?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用
insertBefore()
而不是before()
http:// /jsfiddle.net/TjxBL/2/
Use
insertBefore()
instead ofbefore()
http://jsfiddle.net/TjxBL/2/