在CSS中选择特定元素

编程入门 行业动态 更新时间:2024-10-27 15:17:40
本文介绍了在CSS中选择特定元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

很抱歉,非常通用的帖子标题。但我在这之后是这样的:

Sorry about the very generic post title. But what I'm after here is this:

<div id="my-div"> <span> <a href="#">link 1</a> <a href="#">link 2</a> </span> <a href="#">link 3</a> </div>

如何在CSS中选择link 3没有编辑该Html有在所有。这是提交的html,我需要选择链接3而不选择链接1和2.

How would I select 'link 3' in CSS? Without editing that Html there at all. This is the html that presented with and I need to select link 3 without selecting link 1 and 2.

任何想法?

推荐答案

您发布的字面意思是查找 div div ,并且是其父级的直接子级。

What you posted literally means "Find any a that are inside of div#my-div and are the direct child of their parent."

使用

div#my-div > a

使用> 更改说明to:找到 div#my-div 的直接后代的任何 a

Using the > changes the description to: "Find any a that are the direct descendents of div#my-div" which is what you want.

更多推荐

在CSS中选择特定元素

本文发布于:2023-10-31 01:59:37,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1544654.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:元素   CSS

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!