为不同尺寸设备的不同 CSS 样式规则设置媒体查询
要为不同的 CSS 样式规则设置媒体查询,你可以尝试运行以下代码 −
例如
<html> <head> <style> body { background-color: lightpink; } @media screen and (max-width: 420px) { body { background-color: lightblue; } } </style> </head> <body> <p>If screen size is less than 420px, then it will show lightblue color, or else it will show light pink color</p> </body> </html>
广告