如何使用CSS将前N个孩子的身高设置为其父母的最大高度? [英] How to set first N children height to its parent max-height using CSS?

查看:87
本文介绍了如何使用CSS将前N个孩子的身高设置为其父母的最大高度?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经问过一个问题,并使用 jQuery 解决了自己的问题,但我想用 CSS 来解决问题。我使用纯CSS。



以下是答案

@Mamun建议我问一个新问题,所以我再问一次。

详情请参阅问题。



<上一个问题的更新



我动态前置 div( .class-row-notification )转换为另一个div( .class-append-con )。

现在我想将前5个div height 设置为其父 max-height margin padding bottom-border c $ c>等)。

添加前五个div类( .class-row-notification )( ( children div )== max-height .class- append-con )(父div

如何做到这一点?如果通过CSS,它应该是跨浏览器的。



更新的jsFiddle



谢谢。

解决方案

我在这里尝试了一些东西,我认为这就是你意思是

  .class-append-con:nth-​​child(-n + 5){
height:100% ;
}

这是你想要的例子


I have already asked a question and solved myself using jQuery, but I want to solve this using CSS.I'm using plain CSS.

Here is Answer.
@Mamun suggested me to ask a new question, so I have asked it again.
For details please refer question.

Update From Previous question

I have dynamically prepended divs (.class-row-notification) to another div (.class-append-con).
Now I want to set first 5 divs height to its parent's max-height (Including margin, padding, bottom-border etc.).

Addition of first five div class (.class-row-notification)(children div) == max-height of class(.class-append-con)(parent div)

How to do that? If through CSS, it should be cross-browser.

Updated jsFiddle

Thank you.

解决方案

I tried somthing here and i think this is what you mean

.class-append-con :nth-child(-n+5) {
    height: 100%;
} 

Here is the example you wanted

这篇关于如何使用CSS将前N个孩子的身高设置为其父母的最大高度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆