我正在尝试更改Web窗体上的字体大小,以使其在移动设备上显示时看起来更小(当前使用android)。通过更改css文件以将文本呈现为font-size:small,当从浏览器查看时,它可以正常工作,但是当在电话上查看同一页面时,文本似乎不会变小,因此所有内容(包括控件)看起来都很大。使用引导程序,但不确定如何使用响应字体大小,但是我希望上面的工作正常,这是标题
<head runat="server">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<meta charset="utf-8">
<meta name="generator" content="Bootply" />
<meta name="viewport" content="width=device-width, initial-scale=1">
将其包含<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
在标题中,然后您可以根据Chris Coyer的CSS技巧对移动设备使用媒体查询:
/* Smartphones (portrait and landscape) ----------- */
@media only screen
and (min-device-width : 320px)
and (max-device-width : 480px) {
.targetClass {
font-size: 2em;
}
}
/* Smartphones (landscape) ----------- */
@media only screen
and (min-width : 321px) {
.targetClass {
font-size: 2em;
}
}
/* Smartphones (portrait) ----------- */
@media only screen
and (max-width : 320px) {
.targetClass {
font-size: 2em;
}
}
/* iPads (portrait and landscape) ----------- */
@media only screen
and (min-device-width : 768px)
and (max-device-width : 1024px) {
.targetClass {
font-size: 2em;
}
}
/* iPads (landscape) ----------- */
@media only screen
and (min-device-width : 768px)
and (max-device-width : 1024px)
and (orientation : landscape) {
.targetClass {
font-size: 2em;
}
}
/* iPads (portrait) ----------- */
@media only screen
and (min-device-width : 768px)
and (max-device-width : 1024px)
and (orientation : portrait) {
.targetClass {
font-size: 2em;
}
}
/* Desktops and laptops ----------- */
@media only screen
and (min-width : 1224px) {
.targetClass {
font-size: 2em;
}
}
/* Large screens ----------- */
@media only screen
and (min-width : 1824px) {
.targetClass {
font-size: 2em;
}
}
/* iPhone 4 ----------- */
@media
only screen and (-webkit-min-device-pixel-ratio : 1.5),
only screen and (min-device-pixel-ratio : 1.5) {
.targetClass {
font-size: 2em;
}
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句