html - 我可以使用 css 通过标题唯一地标识或拉出一个类或 div 吗?

标签 html css content-management-system joomla2.5

我有两个链接,它们共享相同的样式(class 和 div)。但问题是,我不知道从哪里提取 html。所以我想为每个链接赋予不同的样式。所以我想知道是否可以仅使用标题来定位类或 div?

这是生成的 html:

<div class="event_legend_container">
    <div style="border-color:" class="event_legend_item activechildcat">
        <div style="border-color:" class="event_legend_name">
            <a title="HR Calender" href="/using-joomla/human-resources/2012-10-17-10-31-30/month.calendar/2013/05/20/85">
                HR Calender
            </a>
        </div>
</div>
<div style="border-color:#d3d3d3" class="event_legend_item ">
    <div style="border-color:#d3d3d3" class="event_legend_name">
        <a title="All Categories ..." href="/using-joomla/human-resources/2012-10-17-10-31-30/month.calendar/2013/05/20/-">
            All Categories ...
        </a>
    </div>
</div>

最佳答案

您可以使用 attribute selector :

a[title*="HR Calender"]{
  color:red;
}
a[title*="All Categories"]{
  color:green;
}

这是完整列表:http://www.w3.org/TR/selectors/#selectors

关于html - 我可以使用 css 通过标题唯一地标识或拉出一个类或 div 吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16649717/

相关文章:

html - 如何在 Shopify 的 theme.liquid 文件中添加悬停图像

javascript - 加载视频后页面不会重新加载

html - 为什么我的 CSS 视差不起作用?

html - 在屏幕中居中 BIG div

html - 垂直居中 - 如何将内联元素垂直放置在 block 级元素的中间

javascript - 如果发生某种情况,如何链接到 CSS?

php - 我已经编码的网站的内容管理

css - CSS3 中带有过渡的延迟模糊过滤器

php - 正则表达式识别并剥离字符串中的 '.00'

c# - 如何强制 Kentico 默认生成小写 url?