字体大小自适应屏幕分辨率 CSS解决方案

时间:2024-04-15 11:48:11

viewpoint

css3提供了一些与当前viewpoint相关的元素,vw,vh,vim等。

“viewpoint” = window size

vw = 1% of viewport width
1vh = 1% of viewport height
1vmin = 1vw or 1vh, 最小
1vmax = 1vw or 1vh, 最大

兼容性:chrome 20+/ safari 6+/ IE 10+ / FF 19+ / IOS 6+

 

<!DOCTYPE HTML>  
<html>  
<head>  
    <meta charset="UTF-8">  
    <title>Demo</title>
    <style type="text/css">
        #text { font-size: 4vw;}
    </style>
</head>

<body>
    <div id="text">
        测试文本测试文本
    </div>
</body>
</html>