我有一些列表项,第一个是特色类,过了一些没有.有了CSS,我想选择列表中没有特色类的第一个项目......
代码如下:
<ul>
<li class="featured"></li>
<li class="featured"></li>
<li></li>
<li></li>
<li></li>
</ul>
Run Code Online (Sandbox Code Playgroud)
我尝试了以下但没有效果:
ul li:not(.featured):first-child {
/* Do some stuff here */
}
Run Code Online (Sandbox Code Playgroud)
关于如何在不诉诸jQuery的情况下做到这一点的任何想法?
更新 如果能够提供帮助,那么添加非要素类的能力确实存在.例如:
<ul>
<li class="listing featured"></li>
<li class="listing featured"></li>
<li class="listing"></li>
<li class="listing"></li>
<li class="listing"></li>
</ul>
Run Code Online (Sandbox Code Playgroud) 我目前正在开发一个tumblr主题,并构建了一个jQuery JSON thingamabob,它使用Tumblr API执行以下操作:
用户可以点击"帖子类型"链接(例如视频帖子),在这个阶段,jQuery将使用JSON获取与该类型相关的所有帖子,然后在指定区域中动态显示它们.
现在一切都工作得非常好,除了Tumblr是Tumblr并且他们的服务器时不时地敲门,Tumblr API有时候离线了.现在我无法预见此函数何时会关闭,这就是为什么我想显示一些通用错误消息,如果JSON(无论出于何种原因)无法加载帖子.
您会看到我已经编写了一些代码来显示错误消息,当jQuery找不到与该帖子类型相关的任何帖子但是它不包含任何服务器错误.注意:我有时会收到此错误:
无法加载资源:服务器响应状态为503(服务暂时不可用)
这是503错误消息,我需要编写一些代码,但我有点无能:)
这是jQuery JSON代码:
$('ul.right li').find('a').click(function() {
var postType = this.className;
var count = 0;
byCategory(postType);
return false;
function byCategory(postType, callback) {
$.getJSON('{URL}/api/read/json?type=' + postType + '&callback=?', function(data) {
var article = [];
$.each(data.posts, function(i, item) {
// i = index
// item = data for a particular post
switch(item.type) {
case 'photo':
article[i] = '<div class="post_wrap"><div class="photo" style="padding-bottom:5px;">'
+ '<a href="' + item.url + '" title="{Title}" class="type_icon"><img src="http://static.tumblr.com/ewjv7ap/XSTldh6ds/photo_icon.png" alt="type_icon"/></a>'
+ '<a …Run Code Online (Sandbox Code Playgroud) 目前我的H1标签设置为#8c0000(深红色).
使用jQuery,我想获得H1的颜色,然后根据h1的颜色进行计算,以确定如果我想要几个阴影更暗的新颜色的十六进制值.
这样做的原因是我想通过创建"插入"文本阴影来使用CSS3的新文本阴影属性来创建"浮雕"效果.
我相信,要获得H1元素的颜色,可以使用:
('H1').css('color');
Run Code Online (Sandbox Code Playgroud)
但是,如何计算更暗的阴影呢?
PS - 看到H1颜色将动态设置,我不能只是在固定的文本阴影中进行硬编码,这就是我需要计算的原因......
任何帮助将不胜感激.先感谢您
好的,所以我正在尝试使用 jQuery JSON 创建一个“按类型订购帖子”来获取数据......所有帖子类型都适用于 Chrome、Safari、FF。但是在 IE 中,当我使用 JSON 过滤帖子时,视频/音频帖子将不会显示(可能与嵌入有关?)。
有没有人知道这是怎么回事?!这是代码:
<script>
$('#order_by ul li').find('a').click(function() {
var postType = this.className;
var count = 0;
byCategory(postType);
return false;
function byCategory(postType, callback) {
$.getJSON('{URL}/api/read/json?type=' + postType + '&callback=?', function(data) {
var article = [];
$.each(data.posts, function(i, item) {
// i = index
// item = data for a particular post
switch(item.type) {
case 'photo':
article[i] = '<div class="post_wrap"><div class="photo"><a href="'
+ item.url
+ '" title="View Full Post" class="type_icon"><img src="http://static.tumblr.com/ewjv7ap/0yplawef6/link_photo.png" /></a><a href="'
+ item.url …Run Code Online (Sandbox Code Playgroud) 以下代码可以在所有浏览器中完美运行,禁止IE浏览器.照常.这是需要发生的事情:
正如我所说,到目前为止代码工作得非常好,除了在IE中.任何有新鲜眼睛(和完整的发际线)的人都可以看看这个吗?可以做到与众不同吗?
function getRGB(color) {
// Function used to determine the RGB colour value that was passed as HEX
var result;
// Look for rgb(num,num,num)
if (result = /rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/.exec(color)) return [parseInt(result[1]), parseInt(result[2]), parseInt(result[3])];
// Look for rgb(num%,num%,num%)
if (result = /rgb\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*\)/.exec(color)) return [parseFloat(result[1]) * 2.55, parseFloat(result[2]) * 2.55, parseFloat(result[3]) * 2.55];
// Look for #a0b1c2
if (result = /#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/.exec(color)) return [parseInt(result[1], 16), parseInt(result[2], 16), parseInt(result[3], 16)];
// Look for #fff
if (result = /#([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])/.exec(color)) return …Run Code Online (Sandbox Code Playgroud) 我失去了我的发际线,可能是一分钟.如果你将 Chrome/Firefox中的这个网站与IE 进行比较,你会注意到如果你将鼠标悬停在每个条目上,在Chrome/FF中它将获得轻微的绿色背景,而在IE中,zilch/nada/zero/zippo ......
编码联谊会中的任何人都可以给出一些指示吗?不可否认,jQuery不是我的强项,这是代码有助于悬停效果:
$('div.availableNowListing').hover( function() {
$(this).addClass('focus');
}, function() {
$(this).removeClass('focus');
});
Run Code Online (Sandbox Code Playgroud)
和CSS:
div.availableNowListingCatHeading {
display: none;
border: 1px solid #e6e6e6;
margin-top: 20px;
overflow: hidden;
background-color: #efefef;}
div.availableNowListingCatHeading h3 {
float: left;
margin-left: 80px;
margin-top: 20px;}
div.availableNowListingCatHeading img {
margin: 5px;
float: left;
border: 1px solid #e3e3e3;}
.focus {
background-color: #dbfcab;}
Run Code Online (Sandbox Code Playgroud)
在此先感谢您看一眼:)