Dimensi CSS
Properti Dimensi CSS
屬性 | 描述 |
---|---|
height | 設置元素的高度。 |
line-height | 設置行高。 |
max-height | 設置元素的最大高度。 |
max-width | 設置元素的最大寬度。 |
min-height | 設置元素的最小高度。 |
min-width | 設置元素的最小寬度。 |
width | 設置元素的寬度。 |
Instance
Tetapkan ketinggian imej menggunakan peratusan
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>php中文網(php.cn)</title> <style> html {height:100%;} body {height:100%;} img.normal {height:auto;} img.big {height:30%;} img.small {height:10%;} </style> </head> <body> <img class="normal" src="/upload/course/000/000/006/5809800b44336872.jpg" width="95" height="84" /><br> <img class="big" src="/upload/course/000/000/006/5809800b44336872.jpg" width="95" height="84" /><br> <img class="small" src="/upload/course/000/000/006/5809800b44336872.jpg" width="95" height="84" /> </body> </html>
Jalankan program untuk mencubanya
Contoh
Tetapkan ketinggian minimum elemen
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>php中文網(php.cn)</title> <style> p { min-height:100px; background-color:yellow; } </style> </head> <body> <p>這一段的最小高度設置為100 px。</p> </body> </html>
Jalankan atur cara untuk mencubanya