2017-06-16 8 views
-2

今私は、divline-wrap,word-breakとランダムに作成した0と1の1行が背景を満たしています。それは素晴らしく見えますが、長さは固定されていて、異なる画面サイズでは長すぎる/短すぎます。htmlに背景としてテキストを追加するには?

これについてもっと良い方法がありますか?私はちょうど0と1で不気味な背景がほしいです。

答えて

0

あなたは追加のスタイルであなたのdivを使用することができますプロパティ。

.background { 
    overflow-x: hidden; // hide scroll-x 
    overflow-y: hidden; // hide scroll-y 
    word-wrap: break-word; // word wrap text 
    width:97%; // width > 97% absolut position div will overflow and cause screen scroll 
    height:97%; // height > 97% absolut position div will overflow and cause screen scroll 
    position: absolute; // this way the div will act as background and it will not interfier with the rest of the components in the html 
} 

あなたはここに&テストにそれを再生することができます:https://jsfiddle.net/fb3yLj8h/1/

+0

をフィドルは私がエラーを追跡する助け、ありがとうございます。私のプロジェクトではなく、フィドルで '高さ'属性が機能しませんでした。理由は、親要素の高さを指定しなかったためです。 –

0

位置プロパティの位置を使用できます。テキストおよびテキストラッパープロパティの場合は、絶対です。位置:相対;全画面表示に

0

テキストエリア:

<!DOCTYPE html> 
    <html> 
     <body> 
     <textarea name="text1" style="width: 100%;height: 100%"></textarea> 
     </body> 
    </html> 

あなたが入力(使用することができませんediteサイズ)にしたい場合:

<!DOCTYPE html> 
    <html> 
    <body> 
     <input type="search" style="width: 100%;height: 100%" > 
    </body> 
    </html> 
関連する問題