jQuery Mobile - 导航栏第 3 方图标
描述
您可以将第三方图标添加到您的导航栏。 为此,只需添加自定义样式以链接到图标并将它们放置在导航栏中。
示例
以下示例演示了在 jQuery Mobile 中使用 导航栏第 3 方图标。
<!DOCTYPE html>
<html>
<head>
<title>Navbars 3rd Party Icons</title>
<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>
<style>
.nav-glyphish-example .ui-btn {
padding-top: 40px !important;
}
.nav-glyphish-example .ui-btn:after {
width: 30px!important;
height: 30px!important;
margin-left: -15px !important;
}
#home:after {
background: url("/jquery_mobile/images/home.png") no-repeat;
}
#notify:after {
background: url("/jquery_mobile/images/notifications.png") no-repeat;
}
</style>
</head>
<body>
<div data-role = "footer" class = "nav-glyphish-example" data-theme = "a">
<div data-role = "navbar" class = "nav-glyphish-example" data-grid = "a">
<ul>
<li><a href = "#" id = "home" data-icon = "custom">Home</a></li>
<li><a href = "#" id = "notify" data-icon = "custom">Notifications</a></li>
</ul>
</div>
</div>
</body>
</html>
输出
让我们执行以下步骤,看看上面的代码是如何工作的 −
将上述 html 代码保存为服务器根文件夹中的 navbar_3rd_party_icons.html 文件。
将此 HTML 文件打开为 http://localhost/navbar_3rd_party_icons.html,将显示以下输出。

