【问题标题】:Row of two components. If the text overflows it should start from left in HTML两个组件的行。如果文本溢出,它应该从 HTML 的左侧开始
【发布时间】:2021-09-27 09:16:39
【问题描述】:

正如您在图像中突出显示的部分中看到的那样,有两个组件。

  1. “直播”蓝色标签
  2. 标题

问题是如果我们使用一行,那么溢出的文本将从第二个组件的起点继续。
我想要的是:我希望溢出的文本从整行的起点开始,例如“Live”标签下的“South Africa”。

任何解决方案/建议都会有所帮助。谢谢!

【问题讨论】:

    标签: html css text alignment row


    【解决方案1】:

    我会使用display: flex;(也为:flex-direction: column;)执行此操作并设置最大宽度以避免文本在活动标签后面继续显示:

    #everthing{
      height: 700px;
      width: 250px;
      display: flex;
      flex-direction: column;
      justify-content: space-around;
      align-items: center;
    }
    
    #title{
      height: 100px;
      width: 250px;
      display: flex;
      flex-direction: column;
      align-items: start;
    }
    <div id="everything">
      <img src="" alt="Main picture">
      <div id="title">
        <img src="" alt="Live">
        <span>Your Title</span>
      </div>
    </div>

    现在您只需插入缺失的数据以及您喜欢的高度或宽度。对我来说,效果很好。我为 Live-Label 使用了图像,但应该可以使用 div。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-04-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-10-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多