如何仅在标题中的 space 上强制 line-break 并防止使用 CSS 进行大写?

How to force line-break only on a space in a title and prevent hypenation with CSS?

我想 CSS 在 space 上强制 break-line 而不是像 "Plan[break-line]individual"

这样的词

我正在使用 Flexbox 制作简单的响应式代码。

HTML

<section class="card-container">
    <div class="card card-inline text-center">
        <div class="card-block">
            <h4 class="card-title">Plan individual</h4>
                <p class="card-text">€10.00 / year</p>
                <button click="#'">Sign in</button>
        </div>
    </div> 
    ...                   
</section>  

style.css

.card-container{
    display: flex;
    height: inherit;
    width: inherit;
}

.card{
    position: relative;
    display: flex;
    flex-direction: column;
    min-width: 0;
    background-color: #fff;
    background-clip: border-box;
    border: 1px solid rgba(0,0,0,.125);
    border-radius: .25rem;
    width: 170px;
}

.card-inline{
    display: inline-flex;
    margin: .75rem;
}

.card-block {
    flex: 1 1 auto;
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

h4.card-title{
    margin: .5rem !important;
    font-size: 100% !important;
}

.text-center{
    text-align: center !important;
}

我尝试了white-space、word-wrap、flex-wrap...但没有成功。 有谁知道如何防止单词连字符?

您包含的代码没有给出您在图像中显示的结果,因此您必须在其他地方有一个 CSS 规则导致它。

但是,您应该可以使用以下内容覆盖它:

h4 {
    hyphens: none;
}

对于更简单的解决方案,只需在 <br/> 标记到您的 html 字词之间。如果你想用 media queries 来定位它,你可以添加一个 class 来根据屏幕宽度打开和关闭中断。