2015-06-11 39 views
0

我喜歡應用CSS將文本與麪包屑中的設計進行匹配。在Microdata + Schema.org中應用CSS?

例如:

<ol itemscope itemtype="http://schema.org/BreadcrumbList"> 
    <li itemprop="itemListElement" itemscope 
     itemtype="http://schema.org/ListItem"> 
    <a itemprop="item" href="https://example.com/dresses"> 
    <span itemprop="name">Dresses</span></a> 
    <meta itemprop="position" content="1" /> 
    </li> 
› <li itemprop="itemListElement" itemscope 
     itemtype="http://schema.org/ListItem"> 
    <a itemprop="item" href="https://example.com/dresses/real"> 
    <span itemprop="name">Real Dresses</span></a> 
    <meta itemprop="position" content="2" /> 
    </li> 
</ol> 

有沒有辦法這樣做呢?

+0

(注意'>'字符無效在此背景下,不能有任何文字作爲「ol」的直接子。我看到Schema.org上的例子包含它;我會盡力改變它。) – unor

回答

1

您可以像使用其他任何元素一樣設置Microdata的元素,例如,使用元素選擇器(ol {color:red;})或在HTML中添加class屬性並使用CSS中的類選擇器(.breadcrumbs {color:red;})。

如果你想利用你現有的微觀數據的屬性,你可以使用attribute selectors,例如:

  • 具有itemprop屬性span元素:

    span[itemprop] {color:red;} 
    
  • 一個span元素的itemprop屬性的值爲name(並且沒有其他值):

    span[itemprop="name"] {color:red;} 
    
  • 具有itemprop屬性具有值nameand possibly other values)一個span元件:

    span[itemprop~="name"] {color:red;}