Tof*_*eer 3 html css jquery-mobile
我希望增加jquery移动应用程序的标头大小.当我这样做时,我需要标题集中.我发现我可以添加如下行:
line-height: 30px;
Run Code Online (Sandbox Code Playgroud)
到了css,但这远远不是一个黑客.我认为必须有更好的方法来做到这一点.
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.0a1/jquery.mobile-1.0a1.min.css" />
<script src="http://code.jquery.com/jquery-1.4.3.min.js"></script>
<script src="http://code.jquery.com/mobile/1.0a1/jquery.mobile-1.0a1.min.js"></script>
<style type="text/css"><!--
.ui-header {
height: 50px;
}
-->
</style>
</head>
<body>
<div data-role="page">
<div data-role="header">
<h1>This Needs To Be Centred Vertically</h1>
</div>
<div data-role="content">
<p>Page content goes here.</p>
</div>
<div data-role="footer">
<h4>Page Footer</h4>
</div>
</div>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
Leo*_*Leo 10
垂直居中块元素文本的最简单方法是使行高与所述元素的高度相同.请注意,这仅在您有一行文本时才有效.
line-height: 30px;
height: 30px;
Run Code Online (Sandbox Code Playgroud)
在内联或表格单元格中,您可以使用它vertical-align: middle来实现相同的效果.
另请注意,强制display: table-cell元素在IE6-7中不起作用.
在你的情况下,我建议采用行高/高度技术.