Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在DIV中动态地在LI中创建一组锚标记。但我看到所有这些锚标签都从父 DIV 中的默认锚标签继承了它的样式。谁能告诉我如何防止这些锚标签从默认锚标签继承它的样式?谢谢。
您的问题可能与继承有关。我建议尝试以下方法:
更详细地参考这些锚点:
div ul li a.class_name
div ul li a#id_name
使用 > 选择器仅将样式应用于该级别:
李>一
在这种情况下,意味着仅将其应用于作为列表元素的直接子元素的锚点。
样式规则是否在同一个样式表中?