[英]how to select image using css
This is my html: 这是我的html:
<div id="content">
<img src="myimg.png" alt="this image need to select"/>
<div class="some">
<img src="another.png" alt="this is not need to select"/>
</div>
</div>
I want to select all image which are inside id content
but not which are inside the div
or span
of content
div ie select all image directly inside the content
div and not the ones that are inside the div
or span
of content div. 我想选择所有图像它们的ID内
content
,但没有哪个是内div
或span
的content
DIV即直接选择中的所有图像content
的div和不属于内的那些div
或span
内容股利。
Any thoughts? 有什么想法吗?
You can use >
to select direct/immediate children of the div like this: 您可以使用
>
选择div的直接/直接子级,如下所示:
#content > img{
// target direct children
}
More Info: 更多信息:
不是专家,但这应该可行-> div#content > img
you can write 你可以写
#content > img {
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.