search

Home  >  Q&A  >  body text

css3怎么限定文字字数

我知道这样可以限制到几行,有没有可以限定文字个数的?

.content{line-height:20px;display: -webkit-box;
    -webkit-line-clamp:3;
    -webkit-box-orient: vertical;
    overflow: hidden;}
PHPzPHPz2778 days ago470

reply all(4)I'll reply

  • PHPz

    PHPz2017-04-17 11:39:06

    I don’t think I’ve seen it before. CSS is at the presentation layer. If you need to limit the number of words, it’s better to use JS to process it. Of course this is just my understanding.

    reply
    0
  • 巴扎黑

    巴扎黑2017-04-17 11:39:06

    It’s better to use js

    reply
    0
  • PHP中文网

    PHP中文网2017-04-17 11:39:06

    The lines of your code are to display ... after the multi-line text exceeds the limited width and height;
    As for limiting the number of words, using CSS can only control the width and height of the container, but it cannot be precise to how many words. character.
    Use JS to handle it.

    reply
    0
  • 怪我咯

    怪我咯2017-04-17 11:39:06

    You can’t directly limit the number of words. Clamp limits it to rows. The number of words is still controlled by js

    reply
    0
  • Cancelreply