隐藏前两段以外的长文字 [英] Hide long text except the first two paragraphs

查看:66
本文介绍了隐藏前两段以外的长文字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的文字很长,除了前两段外,我需要隐藏所有内容. 由于种种原因,我宁愿不为此网站使用jquery.只能使用CSS完成此操作吗? 我知道第n个孩子很可能会解决问题,但是我在制定特定规则时遇到了麻烦.

I have a very long text and I need to hide everything except the first two paragraphs. For various reasons I'd rather not use jquery for this site. Can this be done with css only? I know nth-child most likely will do the trick but I'm having troubles coming up with a specific rule.

<div class="text">
<p>display</p>
<p>display</p>
<p>hide from this point</p>
<p>...</p>
</div>

推荐答案

此代码将为您提供所需的结果:

This code will give you the desired result:

​div.text > p:nth-child(n+3){
    display:none;
}​

这篇关于隐藏前两段以外的长文字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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