Bootstrap 4: hide overflow in card-text

天涯浪子 提交于 2019-12-07 05:55:35

问题


I have a bootstrap 4 card in which I want to hide the overflow of the subtitle (and show "..."). How can I achieve this? If possible with pure bootstrap code...

<div class="card-block p-1">
    <p class="card-title">Test object</p>
    <p class="card-subtitle text-muted">Added by Someone with a long name</p>
    <p class="card-text mx-auto text-center"><span class="badge badge-pill badge-danger">€ 800</span></p>
</div>

回答1:


Just use the text-truncate util class..

     <div class="card">
            <div class="card-block p-1">
                    <p class="card-title">Test object</p>
                    <p class="card-subtitle text-muted text-truncate">Added by Someone with a long name</p>
                    <p class="card-text mx-auto text-center"><span class="badge badge-pill badge-danger">€ 800</span></p>
            </div>
     </div>

https://www.codeply.com/go/bZufg6X1So



来源:https://stackoverflow.com/questions/45694288/bootstrap-4-hide-overflow-in-card-text

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!