ボックスの幅、高さを指定します。
どちらのプロパティもマイナス値を指定することはできません。
値は次の3つの中から選びます。
|
| CSS .sample1 { width: 400px; height: 50px; background: #ff0000; margin: auto; padding: 5px; } .sample2 { width: 70%; height: 50%; background: #0000ff; margin: auto; padding: 5px; } .sample3 { width: auto; height: auto; background: #008000; margin: auto; padding: 5px; } |
XHTML <div class="sample1"> <p> widthに400px、heightに50pxを指定しました。 <⁄p> <⁄div> <div class="sample2"> <p> widthに70%、heightに50%を指定しました。 <⁄p> <⁄div> <div class="sample3"> <p> widthとheightにautoを指定しました。 <⁄p> <⁄div> |
これらの違いを表したのがこちらになります。
ここをクリック!