主頁
CSS
CSS 高度/寬度
Tryit: 以百分比設定高度和寬度
執行 ❯
建立您
自己的
網站
×
更改方向
儲存程式碼
更改主題,深色/淺色
前往 Spaces
<!DOCTYPE html> <html> <head> <style> html, body { height: 100%; } img.one { height: auto; width: auto; } img.two { height: 50%; width: 50%; } </style> </head> <body> <h2>Set the height and width in %</h2> <p>Resize the browser window to see the effect.</p> <p>Original image:</p> <img class="one" src="ocean.jpg" width="300" height="300"><br> <p>Sized image (in %):</p> <img class="two" src="ocean.jpg" width="300" height="300"> </body> </html>