前端 - 用@media设置html的font-size给rem用出现的问题?
问题描述
我的设计稿是640px的,所以设置font-size:62.5%比较写值,但是屏幕缩小后的font-size比例我不知如何把控,不知这样写对不对?min-width: 580px和max-width:580px会不会冲突呢?
@media only screen and (min-width: 640px){ html{font-size: 62.5%; }}@media only screen and (max-width: 640px) and (min-width: 580px){ html{font-size: 62.5%; }}@media only screen and (max-width:580px) and (min-width: 440px){ html{font-size: 54%; }}@media only screen and (max-width:440px) and (min-width: 400px){ html{font-size: 46%; }}@media only screen and (max-width:440px) and (min-width: 400px){ html{font-size: 42%; }}@media only screen and (max-width:400px) and (min-width: 360px){ html{font-size: 40%; }}@media only screen and (max-width:400px) and (min-width: 360px){ html{font-size: 32%; }}
问题解答
回答1:会的,所以bootstrap 里都是差一个pixel. 产生冲突会怎样呢?根据css的原理会选择后定义的效果(选择器权重相同的情况下)。那么这个冲突会发生在屏幕宽度580px的时候。在用户使用的时候这种情况会很少见。但是并不是最佳实践,因为多进行了一次额外渲染。
相关文章:
1. html - 移动端radio无法选中2. javascript - 使用echarts做一个横向的柱状图,但是数据超出坐标轴范围了怎么办?3. JavaScript事件4. javascript - 关于ajax上传多图问题。5. 正则表达式 - python pandas的sep参数问题6. javascript - webpack打包后的bundlejs文件代码不知道什么意思.7. javascript - es6模块加载export的输出值有点没太搞明白8. css - 移动端 line-height安卓错位,苹果机正常用,缩放解决了,可是又出来了占位的问题9. javascript - 在静态页面上用load 引入的页面文件问题?10. javascript - Element UI表格错行
