【发布时间】:2017-02-03 19:28:40
【问题描述】:
我希望在浏览器调整大小以及在移动设备上更改我的字体大小。如果我尝试在 PC 上执行此代码,则此代码有效,但如果我在移动设备上打开我的网站,它不会调整我的文本大小。
我问的是为什么这段代码不工作,而不是怎么写。
Html(关于样式表;用于移动设备的是“handheld.css”):
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" type="text/css" href="style.css" media="only screen and (min-width: 1121px)">
<link rel="stylesheet" type="text/css" href="handheld.css" media="only screen and (max-width:1120px)">
handheld.css:
@media only screen and (max-width:320px) {
#easy {
font-size: 24px;
}
h2{
font-size: 15px;
}
}
@media only screen and (min-width:321px) {
#easy {
font-size: 25px;
}
h2{
font-size: 16px;
}
}
@media only screen and (min-width:380px) {
#easy {
font-size: 26px;
}
h2{
font-size: 17px;
}
}
@media only screen and (min-width:420px) {
#easy {
font-size: 27px;
}
h2{
font-size: 18px;
}
}
#easy{
position: relative;
left: 40%;
font-family: "sweetness", Verdana;
top: -63%;
margin-left: 3px;
fontsize: calc(15px + 3vw);\\this is an alternative to media queries
}
h2{
position: relative;
color:#fff;
text-decoration: none;
font-family: "sweetness", Verdana;
text-shadow:
-0.5px -0.5px 0 #000,
0.5px -0.5px 0 #000,
-0.5px 0.5px 0 #000,
0.5px 0.5px 0 #000;
top: 40px;
fontsize: calc(15px + 2vw); \\this is an alternative to media queries
}
【问题讨论】:
-
@n_palum 我写的是代码不起作用,而不是如何去做!
-
@NiccolòGuidi:这只是一个例子吗?将字体大小增加 1px 是没有意义的...
标签: jquery html css jquery-mobile