简体   繁体   English

如何在css中换行

[英]How to wrap text in css

I got some long text and I want to an auto-line break system. 我收到了一些长文本,我想使用自动换行系统。 Is there any way to do this? 有什么办法吗?

Here is my div; 这是我的div;

<div class="alert alert-warning" style="font-size: 100%; text-align: left;">some long text here!</div>

I tried some solutions but it didn't worked for me. 我尝试了一些解决方案,但对我没有用。

word-wrap: break-word;
overflow: visible;

在此处输入图片说明

EDIT: I am getting same output like above. 编辑:我得到像上面一样的输出。 When I change the width of this div, div's width is changing but text remains same. 当我更改此div的宽度时,div的宽度在变化,但文本保持不变。

<div class="alert alert-warning" style="font-size: 100%; text-align: left; word-wrap: break-word !important;
            overflow: visible !important;">fadsfsd dsf asdf asdf asdf asdf asdffafdsafads dsf sadf asdf sadf asdf sdsdfasdfadsfdasfsdds sadf sadf sadf asdf asfsdfsdfasdfadsfdasfdsa sdaf sadf sadfas d
</div>

try this: 尝试这个:

word-wrap: break-word;
overflow: visible;
width: 800px;

word-wrap only works if a width is specified. 仅在指定width自动换行。

Use this css style it will work: 使用此CSS样式将起作用:

.alert alert-warning{
width:98%;/*set the width by your needs*/
white-space: normal;}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM