Long words are flowing out of the box - How to prevent?

人盡茶涼 提交于 2019-12-17 20:47:07

问题


I have a styled div where I need to add a long text. I have a maximum width ( 100px ) and I need to "make text go down". Now I can't find a solution for my problem: in case of long text, it goes out of the box. I don't have a height problem so it should take any size required.

This is my code:

<style>  
    .infobox { 
        -moz-background-clip: padding;     
        -webkit-background-clip: padding;  
        background-clip: padding-box;      
        border: 6px solid rgba(0,0,0,0.3);
        -webkit-border-radius: 4px;
        -moz-border-radius: 4px;
        border-radius: 4px; 

        padding: 30px;
        width: 100px;
        text-align: center;

        top: 100px;
        left: 200px; 
    } 
</style> 

<div class="infobox"> LOOOOOOOOOOOOOOOOOOOOOOOOOOOONG TEXT :)</div>

回答1:


word-wrap: break-word; should help.

  • Supported in every browser that matters - caniuse.com
  • Read about it on CSS3.info
  • jsFiddle Demo - thanks to @Nacereddine


来源:https://stackoverflow.com/questions/8261738/long-words-are-flowing-out-of-the-box-how-to-prevent

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!