【问题标题】:bootstrap card with min-width image text-truncate, text is not truncated具有最小宽度图像文本截断的引导卡,文本不被截断
【发布时间】:2022-01-21 19:29:58
【问题描述】:

我想制作如下卡片布局:

大布局

中间布局

小布局

..而且布局非常小

还有我的 codepen 链接:https://codepen.io/qarty1/pen/yLzXjrO

<div class="row row-cols-1 row-cols-md-2 g-2 mt-2 mb-2">
    <div class="col">
        <div class="card episode-list h-100">
            <div class="row g-0">
                <div class="col flex-grow-1">
                    <div class="card-body">
                        <h5 class="card-title">1</h5>
                        <p class="card-text mb-1 text-truncate">Goooooooooooooooooooooooooooooooooogle</p>
                        <p class="card-text"><small class="text-muted">2018-12-03</small></p>
                    </div>
                </div>
                <div class="col-3 flex-shrink-0 card-list-right border-start">
                    <a href="#" target="_blank" class="stretched-link">
                        <img src="https://i.ibb.co/2PVD70J/thu.png" class="img-fluid episode-thumb" alt="156 x 208 img here">
                    </a>
                </div>
            </div>
            <div class="card-footer">
                <div class="d-flex">
                    <div class="flex-shrink-0 align-self-center">
                    Keyword
                    </div>
                    <div class="flex-grow-1 ms-2">
                        <span>
                        <a href="#" class="link-dark position-relative" style="white-space: nowrap;">portal</a>
                        </span><span>
                        <a href="#" class="link-dark position-relative" style="white-space: nowrap;">search</a>
                        </span><span>
                        <a href="#" class="link-dark position-relative" style="white-space: nowrap;">site</a>
                        </span><span>
                        <a href="#" class="link-dark position-relative" style="white-space: nowrap;">web</a>
                        </span><span>
                        <a href="#" class="link-dark position-relative" style="white-space: nowrap;">homepage</a>
                        </span>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

如果布局非常小,'Goooooooooooooogle' 不会被截断,但 右图是秋天。

我觉得有问题

这段代码有什么问题?

【问题讨论】:

    标签: twitter-bootstrap flexbox bootstrap-5 card


    【解决方案1】:

    为了使text-truncate 工作,需要将任何min-width 提供给card-text

    .card-text{
      min-width: 2px;
    }
    

    【讨论】:

    • 知道还是不知道...?
    猜你喜欢
    • 2020-12-29
    • 1970-01-01
    • 2010-10-28
    • 2014-10-17
    • 2017-10-10
    • 2021-12-28
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多