在CSS中定位itemprop? [英] Targeting itemprop in CSS?

查看:61
本文介绍了在CSS中定位itemprop?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有Wordpress主题生成的以下两部分代码。
这第一部分代码是为WP页面生成的:

I have the following two sections of code generated by a Wordpress theme. This first section of code is generated for a WP Page:

    <div class="postinner">
        <div itemprop="name">
            <h1 class="pagetitle">My Title</h1>
        </div>
        <p>First line of text</p>
        <p>Second line of text</p>
    </div>

第二部分代码是为WP Post生成的:

This second section of code is generated for a WP Post:

    <div class="postinner">
        <article itemtype="http://schema.org/Article" itemscope="" role="article">
            <div itemprop="headline">
                <h1 class="pagetitle">Hello World!</h1>
            </div>
        </article>
    </div>

我无法找出CSS选择器来专门针对H1标签的文本并将其居中itemprop DIV作为代码的第一部分。

I cannot figure out the CSS selector to specifically target and center the text of the H1 tag within the "itemprop DIV" for the 1st section of code.

此外,我还想用不同的文本颜色来定位和设置WP Post中的H1标签,但是同样,无法弄清楚CSS选择器。

Also, I would also like to target and style the H1 tag in the WP Post with a different text color but again, cannot figure out CSS selector.

推荐答案

您可以尝试使用CSS属性选择器,例如:

You could try using CSS Attribute Selectors, such as:

div[itemprop="name"] h1 {
   color: red;
}

和:

div[itemprop="headline"] h1 {
   color: yellow;
}

示例:http://jsfiddle.net/bEUk8/

这篇关于在CSS中定位itemprop?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆