Css 仅当子元素具有类X时才调整div的高度

Css 仅当子元素具有类X时才调整div的高度,css,sass,Css,Sass,只有当iframe类为my iframe .embed { height: 100px } 我不希望它在以下情况下调整高度: <div class="embed"> <iframe class="my-iframe"> </div> 是否可以在SASS或CSS中执行此操作?当您增加iframe的高度时,只要尚未为div指定高度,父div也将增加。 执行此操作可以增加iframe的高度 <div class="embed">

只有当iframe类为
my iframe

.embed {
   height: 100px
}

我不希望它在以下情况下调整高度:

<div class="embed">
   <iframe class="my-iframe">
</div>


是否可以在SASS或CSS中执行此操作?

当您增加iframe的高度时,只要尚未为div指定高度,父div也将增加。 执行此操作可以增加iframe的高度

<div class="embed">
   <iframe class="some-other-iframe">
</div>

这将只针对包含类“my iframe”的iframe。使用该类更改iframe的高度,父级将相应更改。
iframe[class*="my-iframe"]{
   height: 500px /*or whatever height you want*/
}