Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

第 19 期(W3C标准-HTML):换行 #22

Open
wingmeng opened this issue May 28, 2019 · 0 comments
Open

第 19 期(W3C标准-HTML):换行 #22

wingmeng opened this issue May 28, 2019 · 0 comments

Comments

@wingmeng
Copy link
Collaborator

wingmeng commented May 28, 2019

题目:

在网页中,连续英文单词文本默认是不换行的,所以当容器宽度不够显示时,文本内容会溢出。我们通常的做法是使用 word-break:break-allword-wrap:break-word,但这种强制换行的方式具有不可控性,很容易破坏单词的可读性。请尝试解决这个问题。

测试内容如下:

<p>
  https://juejin.im/search?query=requestAnimationFrame
</p>

要求:容器宽度足够时,整体一行显示;容器宽度不足时,文本内容自动换行,文本中的单词不会被截行。


参考答案:

https://<wbr>juejin.im<wbr>/search?<wbr>query=<wbr>requestAnimationFrame

<wbr> 是一个神奇的标签,可以实现精确换行:当容器宽度不够时,在 <wbr> 这里换行;宽度足够,还是一行显示,非常智能。

参考资料

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant