首页 > 解决方案 > 如何在 HTML 中自动换行?

问题描述

我有一段像下面这样的文本,为了查看整个
文本,我需要滚动到最后。

Hello, this is a piece of text and it is going beyond the screen width and I need scroll to view the whole piece of text which is not so comfortable....

我希望它在屏幕宽度结束时自动换行,例如我想在手机上自动显示如下示例

Hello, this is a piece of text
and it is going beyond the screen
width and I need scroll
to view the whole piece of text
which is not so comfortable....

知道怎么做吗?

标签: javascripthtmlcss

解决方案


您应该阅读HTML 响应式网页设计

响应式网页设计是关于使用 HTML 和 CSS 自动调整网站大小、隐藏、缩小或放大网站,使其在所有设备(台式机、平板电脑和手机)上看起来都不错

下面是我们如何在 CSS 中创建媒体查询。仅当屏幕宽度小于 768 像素时才会应用此 CSS 块。

@media (max-width: 768px) {
    .container {
        width: 100%
    }
}

推荐阅读