html中div不自動(dòng)換行強(qiáng)制不換行的具體實(shí)現(xiàn)

字號(hào):


    1.用<nobr>標(biāo)簽實(shí)現(xiàn)不換行
    代碼如下:
    <div>hello world!<nobr> hello world!<nobr></div>
    2.用<用nowrap元素>標(biāo)簽
    代碼如下:
    <div nowrap>hello world! hello world! hello world! hello world!</div>
    3強(qiáng)制不換行
    代碼如下:
    div{
    white-space:nowrap;
    }
    4.如果是兩個(gè)div,可使用float實(shí)現(xiàn)不換行
    代碼如下:
    div class=class1>hello </div>
    <div class=class2>world! </div>
    .class1 {float:left;}
    5.在div中也可使用display實(shí)現(xiàn)不換行
    代碼如下:
    <div class=class1>hello </div>
    <div class=class2>world! </div>
    .class1 {display:inline;}
    .class2{display:inline;}