获取离父元素最近的 iframe

Get the closest iframe to a parent element

我正在尝试获取最接近父元素的 iframe 元素,以便可以识别我想要使用 css 进行样式化的 iframe:

<div class ="accroche">
  <iframe></iframe>
  <iframe></iframe>
  <iframe></iframe>
  <iframe></iframe>  
</div>

知道 iframe 是由其他工具生成并且无法识别它们的最佳技术是什么

好吧,如果我理解你的问题,它是列表的第一个元素,所以你可以在你的 css 中做类似的事情来设置它的样式:

.accroche iframe:first-child{ … }