如何定位特定的< img> CSS中的div元素? [英] How to target a specific <img> element of a div in CSS?

查看:78
本文介绍了如何定位特定的< img> CSS中的div元素?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个像这样的代码:

I've a code of some what like this:

<div id="foo">
 <img src="bar.png" align="right">
 <img src="cat.png" align="right"> 
</div>

现在我的问题是如何在CSS中指定一个特定的图像有上述代码? p>

Now my question is how do I target a specific image in CSS when having the above code?

推荐答案

您可以向图像添加类

#foo img:nth-child(2) { css here }

#foo img:first-child { css here }
#foo img:last-child { css here }

这篇关于如何定位特定的&lt; img&gt; CSS中的div元素?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆