2012-10-15 38 views
1
<!DOCTYPE HTML> 
<html> 
<head> 
<style> 
    #test{ 
     width: 10px; 
     background-color: blue; 
    } 
</style> 
</head> 
<body> 


<p id="test">a a a a a a a a a</p> 

linebox而不空間從它的父元素

在這個例子中linebox的寬度溢出遵循#TEST


<!DOCTYPE HTML> 
<html> 
<head> 
<style> 
    #test{ 
     width: 10px; 
     background-color: blue; 
    } 
</style> 
</head> 
<body> 


    <p id="test">aaaaaaaaaaaaaaaaa</p> 


</body> 
</html> 

,但與此第二代碼寬度linebox從#test的寬度溢出

什麼處理空間恩linebox

回答

1

我認爲你可以使用

#test{ 
    ... 
    word-wrap:break-word; 
} 

DEMOthis too

+0

但我的問題是什麼解釋是因爲「自動換行:斷字」不是默認的? – user1745031

+0

在第二個例子中,你有一條沒有任何空間的長線。 –

+0

@ user1745031,[這是另一個答案,可能是有用的](http://stackoverflow.com/questions/363425/how-to-wrap-long-lines-without-spaces-in-html)。 –

相關問題