html - CSS选择器以不在另一个元素中的img为目标
问题描述
我想设计一个上面没有“旁边”的图像。我希望样式适用于所有 img 元素,如下所示:
<div class='content'>
(assorted other divs and containers in here)
<img src='http://example.com'>
(could be more <img> elements in here too)
</div>
但我不希望它在这里应用:
<div class='content'>
(assorted other divs and containers in here)
<aside class='quote'>
(assorted other divs and containers in here)
<img src='http://example.com'>
</aside>
</div>
这是我正在尝试的 CSS,但没有运气......
.content :not(aside.quote) img { width:100%; }
由于结构中可以有各种其他 div 和容器,我不能假设 img 将是第一个孩子(或不是第一个孩子)。
我怎样才能得到正确的选择器来做到这一点?
解决方案
推荐阅读
- javascript - 除非我重新加载,否则无法提交表单
- angular - Angular 5中带有图像的选择框
- node.js - 使用 nodejs 和车把
- triggers - 如何在 JIRA 上接收来自 Bitbucket 的钩子并处理此钩子数据?
- android - 如何以 RectangleF 为边界裁剪位图
- java - 如何为liferay定义'java.lang.ClassNotFoundException:com.mysql.cj.jdbc.Driver'
- c++ - 显示输出和输入的函数问题
- reactjs - Material UI TextField 自定义
- c# - CefSharp Chromium 页面加载永远不会完成
- c# - 使用 ClassData 自动测试 TFS/xUnit 仅使用第一个断言