【问题标题】:Text not clipping correctly in CSSCSS 中的文本未正确剪裁
【发布时间】:2022-12-09 21:34:08
【问题描述】:

我的文本剪辑有问题,实际上当我将 div 设置为比文本更小的宽度时,它就会消失。我希望它在缩小尺寸时剪辑单词...我尝试使用overflow: hiddentext-overflow: clip 但它没有按我想要的那样工作。这是代码,在此先感谢您。

CSS:

.finalCutStyleButton{

    width: 90mm;
    height: 20mm;

    background-color: #b3be9e;

    animation: test 2s ease-in;
}

@keyframes test{

    from{
        width: 90mm;
    }
    to{
        width: 30mm;
    }
}
.title{
    
    font-size: 10mm;
    font-family: 'SFProBold', sans-serif;
    font-weight: bold;
    display: inline-block;
    width: auto;
}

HTML:

<div class = "finalCutStyleButton adjustPadding">

   <h1 class = "title">VIDEO EDITING</h1>
</div>

【问题讨论】:

    标签: html css


    【解决方案1】:

    尝试向文本添加相同的关键帧逻辑:

    .finalCutStyleButton {
      width: 90mm;
      height: 20mm;
    
      background-color: #b3be9e;
      display: flex;
      align-items: center;
      animation: test 2s ease-in;
    }
    
    @keyframes test {
      from {
        width: 90mm;
      }
      to {
        width: 30mm;
      }
    }
    .title {
      font-size: 10mm;
      margin: 0 0;
      font-family: "SFProBold", sans-serif;
      font-weight: bold;
      display: inline-block;
     min-width: 100%;
      white-space: nowrap;
      overflow: hidden;
    }
    <div class="finalCutStyleButton adjustPadding">
          <h1 class="title">VIDEO EDITING</h1>
        </div>

    【讨论】:

    • 仍然不是我想要的效果...我希望文本随着时间的推移保持相同的大小,但是当 div 缩小到 X 轴时删除字母,就像文本在 div 下面一样 我不知道我是否解释清楚了我的想法
    • 哦,我想我理解你,检查编辑
    猜你喜欢
    • 2015-05-16
    • 1970-01-01
    • 2015-06-29
    • 2020-12-25
    • 2012-10-02
    • 2018-05-11
    • 2021-02-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多