在响应式设计中的HTML文本中指定首选换行点 [英] Specifying a preferred line break point in HTML text in a responsive design

查看:217
本文介绍了在响应式设计中的HTML文本中指定首选换行点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否有一个CSS或javascript魔术可以在HTML文本中放置一个标记,以便浏览器知道当文本变得狭窄时,换行符创建的位置。有没有这样的事情?

I was wondering if there is a CSS or javascript magic that could place a marker in an html text so that the browser know where the line break creation is preffered when the text gets cramped. Is there such thing?

推荐答案

我认为这很好:

span.line {
  display: inline-block;
}


<p>
  <span class="line">This text should break</span>
  <span class="line">after the word "break"</span>
</p>

当没有足够的空间时,文本在其他位置仍然会中断:

The text still breaks on other places when there is not enough space:

开放演示

这篇关于在响应式设计中的HTML文本中指定首选换行点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆