P粉6680193392023-08-22 20:01:42
Detection is automatic. You have to specify the css that can be used for each screen resolution:
/* 对于所有屏幕,使用14px字体大小 */ body { font-size: 14px; } /* 响应式,对于小屏幕,使用13px字体大小 */ @media (max-width: 479px) { body { font-size: 13px; } }
P粉1455438722023-08-22 18:57:54
Use @media
to query . They fit exactly that need. Here's an example of how they work:
@media (max-width: 800px) { /* 在宽度等于或小于 800px 时显示的 CSS 代码放在这里 */ }
This will only work on devices with a width equal to or less than 800px.
Learn more about media queries on the Mozilla Developer Network.