CSS,自动换行

问题描述 投票:0回答:2

CSS,自动换行。这该怎么做?

我想说出这样的话:

O:
Which is the most horrifying thing/disease you have seen in your medical career?

To:
Which is the most horrifying
thing/disease you have seen
in your medical career?

我用word-wrap: break-word但显示如下:

Which is the most horrifying t
hing/disease yo
u have seen in you
r medical career?
html css word-wrap
2个回答
0
投票

一种可能的解决方案是,如果您希望它是特定的宽度,那么您必须定义它。 例: HTML:

<p>Which is the most horrifying thing/disease you have seen in your medical career?</p>

CSS:

p {
    width: 200px;
    word-wrap: break-word;
}

2
投票

请参阅https://css-tricks.com/almanac/properties/h/hyphenate/

连字符属性另外让你控制连字符。要正常运行,需要在父级上定义语言。最简单的方法就是改变

<body>

<body lang="en">
© www.soinside.com 2019 - 2024. All rights reserved.