省略文字高度的省略号离子宽度

时间:2016-06-14 14:22:11

标签: html css ionic-framework

我试图限制我的文字宽度&高度,我在我的CSS文件中使用了文本溢出:省略号,但我得到了这个结果:

Result

我的CSS是:

.ellipsis{
    white-space: nowrap;
    width: 12em;
    height: 12em;
    overflow: hidden;
    text-overflow: ellipsis;
    border: 1px solid #000000; }

2 个答案:

答案 0 :(得分:2)

Chrome的多行省略号。您可以使用-webkit-line-clamp指定要显示的行数。更多技巧here



.ellipsis {
  width: 12em;
  overflow: hidden;
  border: 1px solid #000000;
  display: -webkit-box;
  -webkit-line-clamp: 5;
  -webkit-box-orient: vertical;
}

<p class="ellipsis">
  Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Maecenas porttitor congue massa. Fusce posuere, magna sed pulvinar ultricies, purus lectus malesuada libero, sit amet commodo magna eros quis urna.
</p>
&#13;
&#13;
&#13;

答案 1 :(得分:0)

谢谢大家, 我找到了一个简单的解决方案:Pure CSS read more toggle

HTML:

 <div>
  <input type="checkbox" class="read-more-state" id="post-1" />

  <p class="read-more-wrap">Lorem ipsum dolor sit amet, consectetur adipisicing elit. <span class="read-more-target">Libero fuga facilis vel consectetur quos sapiente deleniti eveniet dolores tempore eos deserunt officia quis ab? Excepturi vero tempore minus beatae voluptatem!</span></p>

  <label for="post-1" class="read-more-trigger"></label>
</div>

CSS:

.read-more-state {
  display: none;
}

.read-more-target {
  opacity: 0;
  max-height: 0;
  font-size: 0;
  transition: .25s ease;
}

.read-more-state:checked ~ .read-more-wrap .read-more-target {
  opacity: 1;
  font-size: inherit;
  max-height: 999em;
}

.read-more-state ~ .read-more-trigger:before {
  content: 'Show more';
}

.read-more-state:checked ~ .read-more-trigger:before {
  content: 'Show less';
}

.read-more-trigger {
  cursor: pointer;
  display: inline-block;
  padding: 0 .5em;
  color: #666;
  font-size: .9em;
  line-height: 2;
  border: 1px solid #ddd;
  border-radius: .25em;
}

/* Other style */ 
body {
  padding: 2%;
}

p {
  padding: 2%;
  background: #fff9c6;
  color: #c7b27e;
  border: 1px solid #fce29f;
  border-radius: .25em;
}