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

mutmk8jj  于 2023-09-28  发布在  其他
关注(0)|答案(1)|浏览(125)

这个问题已经有答案了

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

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

hmtdttj4

hmtdttj41#

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

  1. <div class="event-card">
  2. <h2><?= $event->title ?></h2>
  3. <p class="event-description"><?= substr($event->description, 0, 100) ?>...</p>
  4. <button class="details-button">Details</button>
  5. <div class="full-description">
  6. <p><?= $event->description ?></p>
  7. </div>

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

  1. .event-card {
  2. border: 1px solid #ccc;
  3. padding: 10px;
  4. margin: 10px;
  5. max-width: 300px; /* Set a max width for the card */
  6. }
  7. .event-description {
  8. overflow: hidden;
  9. max-height: 60px; /* Limit the height of the description */
  10. }
  11. .full-description {
  12. display: none; /* Initially hide the full description */
  13. margin-top: 10px;
  14. }

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

  1. <script>
  2. $(document).ready(function() {
  3. $(".details-button").click(function() {
  4. $(this).siblings(".full-description").toggle();
  5. });
  6. });
  7. </script>

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

展开查看全部

相关问题