我正在尝试在tabbar
中创建一个jquery-mobile
控制器,但我对jquery-mobile
api的演示进行了介绍:http://demos.jquerymobile.com/1.4.5/tabs/#&ui-state=dialog失败:
结果变为:
您会看到这里有两个问题:
1)three
向下偏移。
2)我想navbar
(在iOS
中称为tabbar
)位于page
的底部。
我的代码如下:
<!DOCTYPE html>
<html lang="en">
<head>
<!--<meta http-equiv="content-type" content="text/html; charse=utf-8">-->
<meta charset="UTF-8">
<title></title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="../css/jquery.mobile-1.4.0.css" rel="stylesheet">
<script src="../js/lib/jquery-2.0.3.js"></script>
<script src="../js/lib/jquery.mobile-1.4.0.js"></script>
</head>
<body>
<footer data-position="fixed">
<div data-role="tabs" id="tabs">
<div data-role="navbar">
<ul>
<li><a href="#one" data-ajax="false">one</a></li>
<li><a href="#two" data-ajax="false">two</a></li>
<li><a href="ajax-content-ignore.html" data-ajax="false">three</a></li>
</ul>
</div>
<div id="one" class="ui-body-d ui-content">
<h1>First tab contents</h1>
</div>
<div id="two">
<ul data-role="listview" data-inset="true">
<li><a href="#">Acura</a></li>
<li><a href="#">Audi</a></li>
<li><a href="#">BMW</a></li>
<li><a href="#">Cadillac</a></li>
<li><a href="#">Ferrari</a></li>
</ul>
</div>
</div>
</footer>
</body>
</html>
最佳答案
尝试通过以下方式使用navbar插件:
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.css">
<script src="https://code.jquery.com/jquery-1.11.3.min.js"></script>
<script src="https://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js"></script>
</head>
<body>
<div data-role="page" id="pageone">
<div data-role="header">
<h1>Welcome To My Homepage</h1>
</div>
<div data-role="main" class="ui-content">
<p>My Content..</p>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed ac metus at quam consectetur feugiat. Quisque blandit vulputate turpis, eu molestie sem dapibus id. Etiam mattis odio quam, id facilisis nisi commodo ac. Duis orci ex, auctor vitae mi quis, elementum dictum leo. Fusce ullamcorper dignissim justo, at facilisis velit facilisis vitae. Sed quis efficitur lorem. Integer in molestie felis. Maecenas cursus tempor consequat. Aliquam dapibus accumsan aliquet. Donec non eleifend mauris. Fusce vitae efficitur purus. Aenean sed imperdiet nibh, et tristique lorem. Donec volutpat sem orci, vel ornare sapien tempus ut. Pellentesque lacinia, libero ac tincidunt vulputate, tortor leo placerat ipsum, ut finibus sem est a nunc. Praesent quis condimentum dolor.
</p>
</div>
<div data-role="footer">
<div data-role="navbar">
<ul>
<li><a href="#pageone">Home</a></li>
<li><a href="#pagetwo">Page Two</a></li>
<li><a href="#search">Search</a></li>
</ul>
</div>
</div>
</div>
<div data-role="page" id="pagetwo">
<div data-role="header">
<h1>Welcome To Page Two</h1>
</div>
<div data-role="main" class="ui-content">
<p>This is page two!</p>
</div>
<div data-role="footer">
<div data-role="navbar">
<ul>
<li><a href="#pageone">Home</a></li>
<li><a href="#pagetwo">Page Two</a></li>
<li><a href="#search">Search</a></li>
</ul>
</div>
</div>
</div>
<div data-role="page" id="search">
<div data-role="header">
<h1>Welcome To SEARCH PAGE</h1>
</div>
<div data-role="main" class="ui-content">
<p>SEARCH!</p>
</div>
<div data-role="footer">
<div data-role="navbar">
<ul>
<li><a href="#pageone">Home</a></li>
<li><a href="#pagetwo">Page Two</a></li>
<li><a href="#search">Search</a></li>
</ul>
</div>
</div>
</div>
</body>
</html>