Fabrizio Cocco
Fabrizio Cocco

Reputation: 171

Set width of children as width of parent

I have following structure:

<div id="1">
<div class="clone"></div>
</div>

<div id="2">
<div class="clone"></div>
</div>

And i want to say to every .clone that the shoud use the width of parent id. Use auto or 100% isn't an option, because the clone is position: fixed.

I have a working code:

    $('.clone').width($('.clone').parent().width());

but it could be, that the #1 and #2 are different and my thing wouldn't work then. so i tried

    $('.clone').width($(this).parent().width());

but here have somethind to be wrong. Any help?

Upvotes: 0

Views: 96

Answers (1)

Fabrizio Cocco
Fabrizio Cocco

Reputation: 171

Don't think so far!

Just use:

.clone {
 width:inherit
}

Upvotes: 1

Related Questions