小智 43
对于HTML5网页,我强烈建议使用Viewpoint Width/Height值.它们的功能类似于%,但是随窗口调整大小的字体大小.
例如...
.some-paragraph{
font-size: 5vw;
}
Run Code Online (Sandbox Code Playgroud)
这会将font-size设置为当前视口宽度的5%,即使在重新调整大小时也是如此!
在此处了解更多信息:http://www.w3.org/TR/css3-values/#viewport-relative-lengths
注意:您可能需要考虑到这一点:
<meta name="viewport" content="initial-scale=1">
Run Code Online (Sandbox Code Playgroud)
它被称为响应
@media screen and (max-width: 1024px) {
your font style goes here
}
@media screen and (max-width: 950px) {
your font style goes here
}
@media screen and (max-width: 650px) {
your font style goes here
}
@media screen and (max-width: 480px) {
your font style goes here
}
Run Code Online (Sandbox Code Playgroud)
检查您的媒体查询,如果您使用响应式技术,它们应该控制您的字体大小。
代码示例会有所帮助。
给雷姆一个机会。比 % 或 em 效果更好。
http://snook.ca/archives/html_and_css/font-size-with-rem