• Home
  • Option 1
  • Option 2

And I apply the styles with this classes

我将这些类应用于这些类

#contentheader .cat {
border-top:3px solid #ccc;
background-color:#eee;
overflow:hidden;
}

#contentheader .cat li a {
color:#999;
font-weight:700;
text-decoration:none;
font-size:13px;
display:block;
border-right:1px solid #fff;
float:left;
padding:10px;
}

#contentheader .cat li a:hover {
background-color:#E9E9E9;
}

The problem is that I need the first <li> (Home) to be different, maybe making the text in other color, or maybe making the font wider. I try assigning a class directly to the <li> or the <a> tags, but it doesn't works, it always take the styles in the #contentheader .cat li a class. What is the best way to do this? Thanks

问题是我需要第一个

  • (Home)不同,可能是用其他颜色制作文本,或者可能使字体更宽。我尝试直接将类分配给
  • 或标签,但它不起作用,它总是将#contentheader .cat li中的样式作为一个类。做这个的最好方式是什么?谢谢

  • 或标签,但它不起作用,它总是将#contentheader .cat li中的样式作为一个类。做这个的最好方式是什么?谢谢

    2 个解决方案

    #1


    You need to increase the specificity of that selector to have it override a rule with a lower selector specificity.

    您需要增加该选择器的特异性,以使其覆盖具有较低选择器特异性的规则。

    So if you assign the class to the li element, use #contentheader .cat li.class a, for the a element, use #contentheader .cat li a.class.

    因此,如果将类分配给li元素,请使用#contentheader .cat li.class a,对于a元素,请使用#contentheader .cat li a.class。

    更多相关文章

    1. 单选按钮和多选按钮的样式设置
    2. 工作中遇到的几个CSS样式表的问题
    3. php 把驼峰样式的字符串转换成下划线样式的字符串
    4. 来自php表单的样式电子邮件
    5. 当页面上有多个按钮时,按钮样式在页面加载上有厚的边框
    6. 为什么通过JavaScript更改样式会受到CSS过渡的影响
    7. 如何在execCommand formatBlock 'p'标签中添加类或id或CSS样式?
    8. arcgis api for js入门开发系列十 自定义Navigation控件样式风格
    9. Javascript没有返回样式属性[重复]

    随机推荐

    1. 在 PHP 中格式化并高亮 SQL 语句
    2. QueryPHP V1-beta.5 改进 ORM 设计体验
    3. 定位分析内存泄漏的原因和后果
    4. 树状数据结构存储方式(查询篇)
    5. php重定向后跳转不了
    6. php单点登录实现原理实例详解
    7. php实现进度条原理
    8. php自动生成不重复的id
    9. php中ajax的使用实例讲解
    10. 支付宝app登录授权的infoStr授权登录流程