为什么“ text-align-last”在Safari上不起作用并且行为异常?

时间:2019-07-11 11:39:58

标签: html css safari

这是我有关StackOverflow的第一个问题。直到今天,我始终可以在该网站上找到解决我问题的方法,但是这次我必须寻求帮助。

我需要显示数据库中的文本。此文本包含换行符(不是<br>,只是一个空白的回车符-这就是它保存在数据库中的方式)。这是有道理的。我在Chrome或Firefox上没有问题,但是在Safari上,每个段落的最后一行(或确切的说是一段文字)也是合理的,在单词之间创建了很大的空格。 奇怪的是,当我用光标突出显示文本时,每个段落的最后一行都在左侧。

我应用了text-align-last: left;,但它并没有改变Safari的功能。我也尝试过-webkit-text-align-last: left;,但没有成功。 文本位于<p>中,我尝试将其放入<div>中,但没有任何变化。

.quoteText {
    font-family: Georgia;
    font-style: italic;
    font-size: 18px;
    margin-top: 20px;
    margin-left: 3%;
    margin-right: 3%;
}
.justified {
    white-space: pre-line;
    text-align: justify;
    text-align-last: left;
}
<p class="quoteText justified">
            How often since then has she wondered what might have happened if she&#039;d tried to remain with him; if she’d returned Richard&#039;s kiss on the corner of Bleeker and McDougal, gone off somewhere (where?) with him, never bought the packet of incense or the alpaca coat with rose-shaped buttons. Couldn’t they have discovered something larger and stranger than what they&#039;ve got. It is impossible not to imagine that other future, that rejected future, as taking place in Italy or France, among big sunny rooms and gardens; as being full of infidelities and great battles; as a vast and enduring romance laid over friendship so searing and profound it would accompany them to the grave and possibly even beyond. She could, she thinks, have entered another world. She could have had a life as potent and dangerous as literature itself.

Or then again maybe not, Clarissa tells herself. That&#039;s who I was. This is who I am--a decent woman with a good apartment, with a stable and affectionate marriage, giving a party. Venture too far for love, she tells herself, and you renounce citizenship in the country you&#039;ve made for yourself. You end up just sailing from port to port.

Still, there is this sense of missed opportunity. Maybe there is nothing, ever, that can equal the recollection of having been young together. Maybe it&#039;s as simple as that. Richard was the person Clarissa loved at her most optimistic moment. Richard had stood beside her at the pond&#039;s edge at dusk, wearing cut-off jeans and rubber sandals. Richard had called her Mrs. Dalloway, and they had kissed. His mouth had opened to hers; (exciting and utterly familiar, she&#039;d never forget it) had worked its way shyly inside until she met its own. They&#039;d kissed and walked around the pond together.

It had seemed like the beginning of happiness, and Clarissa is still sometimes shocked, more than thirty years later to realize that it was happiness; that the entire experience lay in a kiss and a walk. The anticipation of dinner and a book. The dinner is by now forgotten; Lessing has been long overshadowed by other writers. What lives undimmed in Clarissa&#039;s mind more than three decades later is a kiss at dusk on a patch of dead grass, and a walk around a pond as mosquitoes droned in the darkening air. There is still that singular perfection, and it&#039;s perfect in part because it seemed, at the time, so clearly to promise more. Now she knows: That was the moment, right then. There has been no other.
        </p>

我希望整个文本都是合理的,并且每个文本块的最后一行都应该向左对齐。同样,它可以在Chrome和Firefox上运行,但不能在Safari上运行。

Screenshot of how the text is displayed (see the last lines of each block) and how the last line reacts when it is selected

3 个答案:

答案 0 :(得分:4)

实际上,Safari不支持它。 请检查参考: https://developer.mozilla.org/en-US/docs/Web/CSS/text-align-last

答案 1 :(得分:1)

它与野生动物园不兼容

在使用任何新的CSS属性之前,请使用caniuse

进行检查。

答案 2 :(得分:0)

一种解决方法。我仅将文本缩进用于Safari浏览器。