lordofwar
lordofwar

Reputation: 33

Adjust height of div only if child element has class X

.embed {
   height: 100px
}

How can I adjust the height of the div container, only when the iframe class is my-iframe

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

I do NOT want it to adjust the height in the following case:

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

Is it possible to do so in SASS or CSS?

Upvotes: 0

Views: 71

Answers (1)

atomCode
atomCode

Reputation: 902

When you increase the height of the iframe the parent div will also increase as long as the isn't already a height specified for the div. You can increase the height of the iframe doing this

iframe[class*="my-iframe"]{
   height: 500px /*or whatever height you want*/
}

This will target only the iframe that contains the class "my-iframe".

Upvotes: 1

Related Questions