1

ここでHTMLコードについて質問したいのですが、divのサイズ設定に関して少し問題があります。divの幅を70pxに設定すると、コンテンツはまだdivをオーバーフローします。必要なのは、コンテンツがdivの幅を超えると、divの高さが自動的に調整されることです。

何か助けはありますか?ここに私のコードがあります。前もって感謝します

<div class = "center"> the quick brown fox jumps over the lazy dog.the quick brown fox jumps over the lazy dog.the quick brown fox jumps over the 
lazy dog.the quick brown fox jumps over the lazy dog.the quick brown fox jumps over the lazy dog.the quick brown fox jumps 
over the lazy dog.the quick brown fox jumps over the lazy dog.the quick brown fox jumps over the lazy dog.the quick brown 
fox jumps over the lazy dog.the quick brown fox jumps over the lazy dog.the quick brown fox jumps over the lazy dog.the 
quick brown fox jumps over the lazy dog.the quick brown fox jumps over the lazy dog.the quick brown fox jumps over the lazy 
dog.the quick brown fox jumps over the lazy dog. </div>

<style> .center{width:70px;} </style>
4

3 に答える 3

2

このCSSを試してください

.center
 {
    width:70px;
    word-wrap: break-word;
 } 

ブラウザに単語を壊すように強制します。そうしないと、コンテナを壊してしまいます。

于 2012-06-22T08:50:58.077 に答える
1

あなたが説明する望ましい動作はデフォルトの動作です(証明)-そのように機能しない場合は、この動作を妨げるスタイルがいくつかあるので、それらを排除してみてください。

また、<style>タグは頭に配置する必要があり、本文には許可されていないことに注意してください (正確に言うと、HTML5 には属性scopedがありますが、atm はブラウザーでのサポートが非常に不十分です)。

于 2012-06-22T08:52:22.277 に答える
0

次の属性をCSSクラスに追加します

overflow: auto;
于 2012-06-22T08:51:06.570 に答える