下图做好各种版本手机的适配(h5设计稿为750px):
<pre>
@media screen and (max-width: 319px) {
html {
font-size: 85.33333px;
}
}
@media screen and (min-width: 320px) and (max-width: 359px) {
html {
font-size: 85.33333px;
}
}
@media screen and (min-width: 360px) and (max-width: 374px) {
html {
font-size: 96px;
}
}
@media screen and (min-width: 375px) and (max-width: 383px) {
html {
font-size: 100px;
}
}
@media screen and (min-width: 384px) and (max-width: 399px) {
html {
font-size: 102.4px;
}
}
@media screen and (min-width: 400px) and (max-width: 413px) {
html {
font-size: 106.66667px;
}
}
@media screen and (min-width: 414px) {
html {
font-size: 110.4px;
}
}
</pre>
H5页面要求:
1.h5页面长宽高和间距,原则上使用rem作为单位;
2.原页面上如果是px为单位的,以200px = 1rem ;
以下情况为特例:
a.因为background对rem支持的偏差,所以使用background的标签,高宽依旧使用px
不过值减半,图大小减半,例子:
旧版:
<pre>
i {
background: url(../img/..) no-repeat;
display: inline-block;
height: 40px;
vertical-align: middle;
width: 138px;
}
</pre>
新版:
<pre>
i {
background: url(../img/..) no-repeat;
-webkit-background-size: 69px 20px;
background-size: 69px 20px;
display: inline-block;
height: 20px;
vertical-align: middle;
width: 69px;
}
</pre>
b.如果原字体使用的也是rem,则值除以20,例子:
旧版:
<pre>font-size: 2.8rem;</pre>
新版:
<pre>font-size: 0.14rem;</pre>
c.图片排列的,尽量使用百分比来保证列数。
网友评论