codeigniter 如何最小化卡片中的详细文本?[副本]

mutmk8jj  于 8个月前  发布在  其他
关注(0)|答案(1)|浏览(47)

这个问题已经有答案了

How to set the size of the bootstrap text and card size(1个答案)
16天前关闭
我是CodeIgniter 4的初学者。所以我做了一张事件卡片,事件的描述很长。当我尝试将事件数据从数据库放入卡片时,卡片是这样的(卡片的长度取决于描述文本的长度):

所以我想最小化它,所以卡将仍然在一个默认的形状,虽然它有很长的描述。因此,当用户想知道完整的描述,他们应该去按钮的细节。谢谢你的回复。很抱歉我没有解释清楚,希望你能理解我的意思。
我搜索了很多教程,似乎我不能更好地解释给搜索引擎,所以它不知道我的意思。它只是显示如何最小化卡片之间的间距,如何对齐文本或图像,或不同类型的卡片等。我还是找不到答案。

hmtdttj4

hmtdttj41#

在视图文件中创建卡片结构
HTML代码:

<div class="event-card">
<h2><?= $event->title ?></h2>
<p class="event-description"><?= substr($event->description, 0, 100) ?>...</p>
<button class="details-button">Details</button>
<div class="full-description">
    <p><?= $event->description ?></p>
</div>

CSS代码:
最初,您可以根据需要隐藏完整的描述并设置卡片样式。

.event-card {
   border: 1px solid #ccc;
   padding: 10px;
   margin: 10px;
   max-width: 300px; /* Set a max width for the card */
 }

.event-description {
    overflow: hidden;
    max-height: 60px; /* Limit the height of the description */
}

.full-description {
    display: none; /* Initially hide the full description */
    margin-top: 10px;
}

脚本:
jQuery在单击“Details”按钮时切换完整描述的可见性。

<script>
   $(document).ready(function() {
      $(".details-button").click(function() {
        $(this).siblings(".full-description").toggle();
      });
   });
</script>

我希望使用完整的答案并澄清此代码:)

相关问题