前端 - 使用rem设置height和line-height相同时文字没有居中?
本文介绍了前端 - 使用rem设置height和line-height相同时文字没有居中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
问 题
demo在这里:
http://jsbin.com/fihikoheno/edit?html,css,js,output
http://output.jsbin.com/fihikoheno
在安卓手机上会出现这种情况,pc没有任何问题?(ios没有测试)
不知问题出在哪?
<!DOCTYPE html>
<html style="font-size:14px;">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<div>哈哈</div>
</body>
</html>
*{padding:0;margin:0;}
div{
width:30px;
height:1.2rem;
line-height:1.2rem;
background:red;
font-size:10px;
color:#fff;
text-align:center;
}
解决方案
12px以下显示问题 可以采用先整体放大,再用css3缩小的方式解决
这篇关于前端 - 使用rem设置height和line-height相同时文字没有居中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文