如何使用Bootstrap Media对象在第二行中制作省略号媒体标题

时间:2019-06-25 01:25:16

标签: css bootstrap-4

如何使用Bootstrap Media对象在第二行中制作省略号媒体标题?

下图显示3行,如何将其限制为2行,然后省略号

enter image description here

1 个答案:

答案 0 :(得分:0)

使用CSS可能是这样的

.media-body h5 {
  display: -webkit-box;
  overflow: hidden;
  text-overflow: ellipsis;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

img {
  max-width: 50px;
}
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" rel="stylesheet" />

<div class="media">
  <img class="mr-3" src="https://upload.wikimedia.org/wikipedia/commons/thumb/5/5c/Blue_copyright.svg/250px-Blue_copyright.svg.png" alt="image">
  <div class="media-body">
    <h5 class="mt-0"> Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It
      has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop
      publishing software like Aldus PageMaker including versions of Lorem Ipsum.</h5>
    Description does here
  </div>
</div>