为什么我不能在标记标签上使用nth-child?

时间:2015-07-05 16:52:55

标签: html css css-selectors

我的代码中没有任何东西会覆盖这个选择器,所以我很困惑为什么它不起作用。我用Google搜索并问了几个朋友他们不知道。我检查服务器不只是花了一段时间来更新文本更新页面,它似乎很好。

CSS

<p><mark>warri0r</mark>Yes</p>
<p><mark>j3w1sh</mark>No</p>
<p><mark>MrGuy</mark>I don't know</p>
<p><mark>explode_</mark>Maybe...</p>
<p><mark>USAUSAUSA</mark>Why not?</p>
<p><mark>Samuel01</mark>Absolutely</p>

HTML

  int *marks[4];
  cout<<"\nPlease enter marks of PF: ";
  cin>>*marks[0];
  cout<<"\nPlease enter marks of LA: ";
  cin>>*marks[1];
  cout<<"\nPlease enter marks of CS: ";
  cin>>*marks[2];
  cout<<"\nPlease enter marks of Phy: ";
  cin>>*marks[3];
  cout<<"\nPlease enter marks of Prob: ";
  cin>>*marks[4];

3 个答案:

答案 0 :(得分:3)

mark:nth-child(even)不起作用,因为它是<p>的唯一孩子。

重写你的CSS:

p:nth-child(even) mark {
    background: #000;
}

(选择偶数<mark>的{​​{1}})

here

答案 1 :(得分:1)

因为nth-child(2n)查找父元素以查找子元素。

要轻松理解它:

将代码包装在div中。使用mark访问偶数段,该mask甚至是父div <body>的子项。

您的案例不需要父div mask,因为mark { color: #CCC; background: #333; padding: 5px; margin: 5px; } .mark p:nth-child(even) mark { background: #000; }是父级。仅出于解释目的,我添加了课程<div class="mark"> <p> <mark>warri0r</mark>Yes</p> <p> <mark>j3w1sh</mark>No</p> <p> <mark>MrGuy</mark>I don't know</p> <p> <mark>explode_</mark>Maybe...</p> <p> <mark>USAUSAUSA</mark>Why not?</p> <p> <mark>Samuel01</mark>Absolutely</p> </div>

rac_textSignal
map

答案 2 :(得分:0)

因为nth-child在像这样的元素中使用:

p

现在from multiprocessing import Process, Queue, Manager, Pool import time from datetime import datetime def results_producer(the_work, num_procs): results = Manager().Queue() ppool = Pool(num_procs) multiplier = 3 #step = len(the_work)/(num_procs*multiplier) step = 100 for i in xrange(0,len(the_work), step): batch = the_work[i:i+step] ppool.apply_async(do_work1, args=(i,batch,results))#,callback=results.put_nowait) return (ppool, results) def results_consumer(results, total_work, num_procs, pool=None): current = 0 batch_size=10 total = total_work est_remaining = 0 while current < total_work: size = results.qsize() est_remaining = total_work - (current + size) if current % 1000 == 0: print 'Attempting to retrieve item from queue that is empty? %s, with size: %d and remaining work: %d' % (results.empty(), size, est_remaining) item = results.get() results.task_done() current += 1 if current % batch_size == 0 or total_work - current < batch_size: if pool is not None and est_remaining == 0 and size/num_procs > batch_size: pool.apply_async(do_work2, args=(current, item, True)) else: do_work2(current,item, False) if current % 1000 == 0: print 'Queue size: %d and remaining work: %d' % (size, est_remaining) def do_work1(i, w, results): time.sleep(.05) if i % 1000 == 0: print 'did work %d: from %d to %d' % (i,w[0], w[-1]) for j in w: #create an increasing amount of work on the queue results.put_nowait(range(j*2)) def do_work2(index, item, in_parallel): time.sleep(1) if index % 50 == 0: print 'processed result %d with length %d in parallel %s' % (index, len(item), in_parallel) if __name__ == "__main__": num_workers = 2 start = datetime.now() print 'Start: %s' % start amount_work = 4000 the_work = [i for i in xrange(amount_work)] ppool, results = results_producer(the_work, num_workers) results_consumer(results, len(the_work), num_workers, ppool) if ppool is not None: ppool.close() ppool.join() print 'Took: %s time' % (datetime.now() - start) 元素中有3个孩子。