jQuery Mobile - 导航栏图标
描述
要将图标添加到导航栏,请使用每个锚点的 data-icon 属性。 默认情况下,图标位于文本的顶部。
示例
下面的示例演示了在 jQuery Mobile 中使用 navbar 图标。
<!DOCTYPE html>
<html>
<head>
<title>Navbar 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>
</head>
<body>
<div data-role = "navbar">
<ul>
<li><a href = "#" data-icon = "mail">Messages</a></li>
<li><a href = "#" data-icon = "user" class = "ui-btn-active">Friends</a></li>
<li><a href = "#" data-icon = "star">Notifications</a></li>
</ul>
</div>
</body>
</html>
输出
让我们执行以下步骤,看看上面的代码是如何工作的 −
将上述 html 代码保存为服务器根文件夹中的 navbar_icons.html 文件。
将此 HTML 文件打开为 http://localhost/navbar_icons.html,将显示以下输出。

