html – 如何在CSS中定位一个div的特定元素?
发布时间:2020-12-14 18:52:48 所属栏目:资源 来源:网络整理
导读:我有一些这样的代码: div id="foo" img src="bar.png" align="right" img src="cat.png" align="right" /div 现在我的问题是在上面的代码中如何在CSS中定位一个特定的图像? 解决方法 您可以向图像OR添加类 #foo img:nth-child(2) { css here } 要么 #foo i
我有一些这样的代码:
<div id="foo"> <img src="bar.png" align="right"> <img src="cat.png" align="right"> </div> 现在我的问题是在上面的代码中如何在CSS中定位一个特定的图像? 解决方法
您可以向图像OR添加类
#foo img:nth-child(2) { css here } 要么 #foo img:first-child { css here } #foo img:last-child { css here } (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |