Gre*_*con 15 css jquery jquery-selectors pseudo-element
对于上下文,这是对早期问题的后续跟进.cssRules我希望将逻辑建立在搜索这些规则效果的jQuery选择器上,而不是深入挖掘.
给定默认属性
.commentarea .author:before {
background-image: url(http://...);
background-position: -9999px -9999px;
/* ... */
}
Run Code Online (Sandbox Code Playgroud)
有选择地修改的
.author[href$="gbacon"]:before /* ... */ {
content: "";
background-position: 0 -140px
}
Run Code Online (Sandbox Code Playgroud)
如何选择各自背景位置具有默认值的伪元素?复制选择器,如
GM_log("size = " + $(".commentarea .author:before").size());
Run Code Online (Sandbox Code Playgroud)
什么都不配.试着.siblings()用
$(".commentarea .author")
.map(function(i) {
GM_log($(this)
.siblings()
.map(function (i) { return $(this).css("background-image") })
.get()
.join(", "))
});
Run Code Online (Sandbox Code Playgroud)
只产生none价值.
有关完整详细信息,请参阅实时页面.这可能吗?
你不能像这样使用:before和:after伪元素.它们的目的是在您指定的选择器之前和之后插入内容.
用法示例:
HTML:
<span class='a'>
Outer
<span class='b'>
Inner
</span>
</span>
Run Code Online (Sandbox Code Playgroud)
CSS:
.a .b:before {
content: "|Inserted using :before|";
}
.a {
color: blue;
}
.b {
color: red;
}
Run Code Online (Sandbox Code Playgroud)
结果:
发生了什么事情是|Inserted using :before|因为它是类b和类的元素的后代,所以文本被插入到内部跨度之前(嗯,真的,预先插入)a.基本上,:before并且:after不要选择; 他们修改.
例:
这不能按预期工作:
HTML:
<span class='a'>
<p>More text</p>
<span class='b'>
<p>More text</p>
Inner
</span>
</span>
Run Code Online (Sandbox Code Playgroud)
CSS:
.a .b:before {
text-size: 100px;
}
Run Code Online (Sandbox Code Playgroud)
什么都没发生:
编辑:
:before不是有效的jQuery选择器:http://api.jquery.com/category/selectors/
我认为你需要使用:beforejQuery插件以外的东西或尝试提取原始规则:http://flesler.blogspot.com/2007/11/jqueryrule.html
| 归档时间: |
|
| 查看次数: |
22733 次 |
| 最近记录: |