源代码:
下载代码
AI 编程工具
点击运行
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>菜鸟教程(runoob.com)</title> <style> #div1 { background-color: yellow; height: 100px; width: max(50%, 300px); } </style> </head> <body> <h1>max() 函数</h1> <p>使用 max() 函数将 #div1 的宽度设置为最大的值,取 50% 或 300px 的最大值:</p> <div id="div1">Some text...</div> <p>重置浏览器大小查看效果。</p> </body> </html>
运行结果: