【问题标题】:CSS background banner for text over circle image圆形图像上文本的 CSS 背景横幅
【发布时间】:2020-06-08 22:12:27
【问题描述】:

我需要一个 CSS 魔法,解释一下 我有这张图

我想动态地添加这样的背景条纹:

但是用css,因为有时候文字太长一行就换行了……

这些是用户用于使文本与图像重叠的 css 类:

.image-container {
    position: relative;
    display: inline-block;
    cursor: pointer;
}

.text-container {
    position: absolute;
    z-index: 999;
    margin: 0 auto;
    left: 0;
    right: 0;
    top: 41%;
    text-align: center; 
    width: 100%; 
    font-size: 24px;
}

非常感谢

【问题讨论】:

    标签: css image background


    【解决方案1】:

    如果更改文本更短可以解决问题,请将这些样式添加到文本中:

    overflow: hidden;
    max-width: as much as you need to make your txt short;
    white-space: nowrap;
    text-overflow: ellipsis;

    【讨论】:

    • 我不知道你为什么需要不透明度?如果您愿意,请与我们分享代码以提供帮助。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-10-18
    • 1970-01-01
    • 2022-01-24
    • 1970-01-01
    相关资源
    最近更新 更多