编程宝库 - 技术改变世界
编程宝库
编程宝库提供了 JS 在线测试工具,可在线测试 JavaScript 代码,你可以在代码编辑器中输入 JavaScript 代码并点击运行查看结果。
源代码
点击运行
<!DOCTYPE html> <html> <head> <style> img.one { height: auto; } img.two { height: 200px; width: 200px; } div.three { height: 300px; width: 300px; background-color: powderblue; } </style> </head> <body> <h1>设置元素的高度和宽度</h1> <p>原始图像:</p> <img class="one" src="http://static.codebaoku.com/pics/f3/4d/f34de5cde0d4e0e3d958176104e9f951.jpeg" width="300" height="300"><br> <p>尺寸调整后的图像 (200x200 像素):</p> <img class="two" src="http://static.codebaoku.com/pics/f3/4d/f34de5cde0d4e0e3d958176104e9f951.jpeg" width="300" height="300"><br> <p>这个 div 的高度和宽度是 300px:</p> <div class="three"></div> </body> </html>
运行结果