简体   繁体   English

将子项的宽度设置为父项的宽度

[英]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.我想对every.clone 说应该使用父ID 的宽度。 Use auto or 100% isn't an option, because the clone is position: fixed.使用自动或 100% 不是一个选项,因为克隆是 position:已修复。

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.但它可能是,#1 和#2 是不同的,然后我的东西就行不通了。 so i tried所以我尝试了

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

but here have somethind to be wrong.但这里有些不对劲。 Any help?有什么帮助吗?

Don't think so far!没想到这么远!

Just use:只需使用:

.clone {
 width:inherit
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM