webkitlineclamp css3,CSS webkit-line-clamp用法及代码示例

-webkit-line-clamp属性用于限制块容器可能包含的行数。仅当显示属性设置为“ -webkit-box”或“ -webkit-inline-box”并且“ -webkit-box-orient”属性设置为“垂直”时,此属性才有效。

用法:

-webkit-line-clamp:none | integer | initial | inherit

属性值:

none:用于指定内容不会被钳位。它是默认值。

例:

-webkit-line-clamp property

/* Clipped text for

comparison */

.content-1 {

width:300px;

display:-webkit-box;

-webkit-box-orient:vertical;

-webkit-line-clamp:2;

overflow:hidden;

}

.content-2 {

width:300px;

display:-webkit-box;

-webkit-box-orient:vertical;

-webkit-line-clamp:none;

overflow:hidden;

}

GeeksforGeeks

-webkit-line-clamp:2

GeeksforGeeks is a computer

science portal with a huge

variety of well written and

explained computer science

and programming articles,

quizzes and interview questions.

-webkit-line-clamp:none

GeeksforGeeks is a computer

science portal with a huge

variety of well written and

explained computer science

and programming articles,

quizzes and interview questions.

输出:

0100a087d2bddabfb7cc19ce398aa8f7.png

integer:它用于指定内容将被裁剪后的行数。此值应大于0。

例:

-webkit-line-clamp

.content-1 {

width:300px;

display:-webkit-box;

-webkit-box-orient:vertical;

-webkit-line-clamp:1;

overflow:hidden;

}

.content-2 {

width:300px;

display:-webkit-box;

-webkit-box-orient:vertical;

-webkit-line-clamp:3;

overflow:hidden;

}

GeeksforGeeks

-webkit-line-clamp:1

GeeksforGeeks is a computer

science portal with a huge

variety of well written and

explained computer science

and programming articles,

quizzes and interview questions.

-webkit-line-clamp:3

GeeksforGeeks is a computer

science portal with a huge

variety of well written and

explained computer science

and programming articles,

quizzes and interview questions.

输出:

3c625fbe2829bd1b68d7cb5e4532b591.png

initial:用于将属性设置为其默认值。

例:

-webkit-line-clamp

/* Clipped text for

comparison */

.content-1 {

width:300px;

display:-webkit-box;

-webkit-box-orient:vertical;

-webkit-line-clamp:2;

overflow:hidden;

}

.content-2 {

width:300px;

display:-webkit-box;

-webkit-box-orient:vertical;

-webkit-line-clamp:initial;

overflow:hidden;

}

GeeksforGeeks

-webkit-line-clamp:2

GeeksforGeeks is a computer

science portal with a huge

variety of well written and

explained computer science

and programming articles,

quizzes and interview questions.

-webkit-line-clamp:initial

GeeksforGeeks is a computer

science portal with a huge

variety of well written and

explained computer science

and programming articles,

quizzes and interview questions.

输出:

0ea4f9055c30bf06b40e80f2785fb861.png

inherit:这用于从其父项继承属性。

支持的浏览器:-webkit-line-clamp属性支持的浏览器如下所示:

谷歌浏览器

火狐浏览器

苹果浏览器

Opera

  • 2
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值