简体   繁体   English

自动换行在 LI 元素中不起作用

[英]Word-wrap not working in LI element

I want to wrap the words automatically within width.我想在宽度内自动包装单词。

<ul class="dropdown-menu" style="width:298px;margin:15px 0 0 0;">
     <li>option 1 </li>
     <li>option 2 option 2 option 2 option 2 option 2 option 2</li>
</ul>

It's now working fine with white-space:normal它现在可以正常使用white-space:normal

ul li{
     white-space:normal;
}

Please Try it...请尝试一下...

ul li {
    word-break: break-all;
}

Add white-space:normal to your CSS element:将 white-space:normal 添加到您的 CSS 元素中:

  word-break: normal;
  white-space: normal;

This works well for me as it wraps correctly with or without whitespace:这对我来说很有效,因为它可以正确包装或不使用空格:

li {
    word-break: break-all;
    }

use word-wrap:break-word;使用word-wrap:break-word; works perfectly fine for me here is the jsfiddle对我来说效果很好,这里是jsfiddle

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

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