代码之家  ›  专栏  ›  技术社区  ›  Saleh

如何通过不允许增加文本来控制DIV标记内的文本?

  •  1
  • Saleh  · 技术社区  · 15 年前

    我有这个CSS代码:

        #d_image {
        float: left;
        width: 320px;
        margin-top: 20px;
        margin-left: 25px;
    }
    #d_coll {
        width: 320px;
        float: left;
    }
    
    #n_div {
        width: 240px;
        text-align: right;
        padding-top: 10px;
        float: left;
        padding-right: 10px;
        padding-left: 0px;
    }
    #n_text {
        text-align: right;
        float: left;
        clear: both;
    }
    #im {
        height: 50px;
        width: 50px;
        float: right;
        padding-right: 15px;
    }
    #n_col {
        clear: both;
        width: 310px;
        float: right;
        border-bottom-width: 2px;
        border-bottom-style: solid;
        border-bottom-color: #CCC;
        padding-bottom: 10px;
    }
    #n_tittle {
        text-decoration: none;
        text-align: right;
        padding-bottom: 10px;
        padding-right: 15px;
    }
    #n_tittle a {
        text-decoration: none;
        text-align: right;
        color: #1C60B3;
    }
    #n_tittle a:hover {
        text-decoration: underline;
        text-align: right;
        color: #FF0000;
    }
    

    我有这个HTML代码:

    <div id="d_coll">
         <div id="d_image">sample text</div>
         <div id="n_text">Here will be photo</div>
    </div>
    <div id="n_col">
         <div id="n_tittle">sample text</div>
         <div id="im">small photo will be here</div>
         <div id="n_div">long text</div>
    </div>
    

    我有道具在里面 N-DIV ,如果我把一个很长的文本放进去,它会在 即时通讯 我希望它里面的文本在到达末尾时转到新行,因为图像应该在文本的右边 即时通讯 .

    我怎么能做到?

    提前谢谢。

    1 回复  |  直到 15 年前
        1
  •  3
  •   Matt Mitchell    15 年前

    要使用自动换行:

    word-wrap: break-word;