今天测试又遇到了个ie8bug:
就是在ie8下设置了高度的input框内的文本不会自动垂直居中,而在其他浏览器及ie9+都正常,大家可以试一下.
解决方法就是像p标签一样设置一下行高,如:line-height: 40px;
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>demo</title>
</head>
<script src="js/jquery-1.11.3.min.js"></script>
<style>
* {padding: 0; margin: 0;}
.ctn {width: 300px; height: 80px; background: red;}
input {border: 2px solid blue; width: 100%; height: 40px; box-sizing: border-box; margin-top: 21px;}
p {height: 100px; background: green; line-height: 100px;}
</style>
<body>
<div class="ctn">
<input type="text" value="一段测试文字" />
</div>
<p>
这是另一段测试文字
</p>
<script>
$("body").css({"color":"red"});
</script>
</body>
</html>