首页
CSS
响应式网页设计媒体查询
试用:在不同屏幕尺寸上更改字体大小
运行 ❯
获取您的
自有
网站
×
更改方向
保存代码
更改主题,深色/浅色
转到 Spaces
<!DOCTYPE html> <html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <style> div.example { background-color: lightgrey; padding: 20px; } @media screen and (min-width: 600px) { div.example { font-size: 80px; } } @media screen and (max-width: 600px) { div.example { font-size: 30px; } } </style> </head> <body> <h2>Change the font size of an element on different screen sizes</h2> <div class="example">Example DIV.</div> <p>When the browser's width is 600px wide or less, set the font-size of DIV to 30px. When it is 601px or wider, set the font-size to 80px. Resize the browser window to see the effect.</p> </body> </html>