我想使用jQuery UI的位置实用程序来将多个元素集中在它们各自的父元素中.这是我想出的:
$(".elementclass").position({
"my": "center center",
"at": "center center",
"of": $(this).parent()
});
Run Code Online (Sandbox Code Playgroud)
不幸的是,这不起作用,因为jQuery对象$(this)在某种程度上不引用此上下文中的定位元素.我该如何解决这个问题?
另一个与Facebook"Like"iframe有关的问题:我根本不明白它的宽度来自哪里.请查看以下代码
<html>
<body>
Test<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.google.com&send=false&layout=button_count&show_faces=false&action=like&colorscheme=light&font&height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; height:21px;" allowTransparency="true"></iframe>Test
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
这是在页面中包含Facebook的"赞"按钮的最小示范.您会注意到按钮周围的"测试"字距相隔很远.Inspector工具显示iframe的宽度精确为300px.但是,浏览iframe的DOM树,我找不到会导致iframe扩展到该宽度的单个元素或样式.iframe中加载的页面使用的CSS甚至没有提及与300px相关的任何内容.
这对我来说很奇怪,但在浏览器中是一致的.最后,我希望iframe简单地适合其内容(参见我之前的问题),但是现在,我很满足于简单地知道为什么它甚至可以扩展到300px宽度.