html – 如何在CSS中定位一个div的特定元素?

前端之家收集整理的这篇文章主要介绍了html – 如何在CSS中定位一个div的特定元素?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我有一些这样的代码
  1. <div id="foo">
  2. <img src="bar.png" align="right">
  3. <img src="cat.png" align="right">
  4. </div>

现在我的问题是在上面的代码中如何在CSS中定位一个特定的图像?

解决方法

您可以向图像OR添加
  1. #foo img:nth-child(2) { css here }

要么

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

猜你在找的HTML相关文章