2014-10-07 76 views
1

Herewhat我试过。我已经给这个标签内跨度。但是,它不会在导航栏中显示图标。OnsenUI - 离子navicon不显示图标

<i class="ion-navicon" style="font-size:32px; vertical-align:-6px;"></i> 

的index.html

<!doctype html> 
<html lang="en" ng-app="my-app"> 
    <head> 
    <meta charset="utf-8"> 
    <link rel="stylesheet" href="onsenui.css"/> 
    <link rel="stylesheet" href="onsen-css-components.css"/> 
    <script src="angular.js"></script> 
    <script src="onsenui.js"></script> 
    <script> 
    ons.bootstrap(); 
    </script> 
    <style> 
.navigation-bar { 
    font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; 
    -webkit-font-smoothing: antialiased; 
    -moz-osx-font-smoothing: grayscale; 
    font-weight: 400; 
    font-size: 17px; 
    -webkit-box-sizing: border-box; 
    -moz-box-sizing: border-box; 
    box-sizing: border-box; 
    -webkit-background-clip: padding-box; 
    background-clip: padding-box; 
    white-space: nowrap; 
    overflow: hidden; 
    word-spacing: 0; 
    padding: 0; 
    margin: 0; 
    font: inherit; 
    color: inherit; 
    background: transparent; 
    border: none; 
    line-height: normal; 
    cursor: default; 
    -webkit-user-select: none; 
    -moz-user-select: none; 
    -ms-user-select: none; 
    user-select: none; 
    z-index: 2; 
    display: block; 
    height: 44px; 
    padding-left: 0; 
    padding-right: 0; 
    background: #f8f8f8; 
    color: #1f1f21; 
    -webkit-box-shadow: none; 
    box-shadow: none; 
    border-bottom: 1px solid #ddd; 
    font-weight: 400; 
    width: 100%; 
    white-space: nowrap; 
    overflow: visible; 
} 
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) { 
    .navigation-bar { 
    border-bottom: none; 
    -webkit-background-size: 100% 1px; 
    background-size: 100% 1px; 
    background-repeat: no-repeat; 
    background-position: bottom; 
    background-image: -webkit-linear-gradient(90deg, #ddd, #ddd 50%, transparent 50%); 
    background-image: -moz-linear-gradient(90deg, #ddd, #ddd 50%, transparent 50%); 
    background-image: -o-linear-gradient(90deg, #ddd, #ddd 50%, transparent 50%); 
    background-image: linear-gradient(0deg, #ddd, #ddd 50%, transparent 50%); 
    } 
} 
.navigation-bar__line-height { 
    line-height: 44px; 
    padding-bottom: 0; 
    padding-top: 0; 
} 
.navigation-bar__bg { 
    background: #f8f8f8; 
} 
.navigation-bar__item, 
.navigation-bar__left, 
.navigation-bar__right, 
.navigation-bar__center { 
    -webkit-box-sizing: border-box; 
    -moz-box-sizing: border-box; 
    box-sizing: border-box; 
    -webkit-background-clip: padding-box; 
    background-clip: padding-box; 
    padding: 0; 
    margin: 0; 
    font: inherit; 
    color: inherit; 
    background: transparent; 
    border: none; 
    line-height: normal; 
    height: 44px; 
    vertical-align: top; 
    overflow: visible; 
    display: block; 
    vertical-align: middle; 
    float: left; 
} 
.navigation-bar__left { 
    max-width: 50%; 
    width: 27%; 
    text-align: left; 
} 
.navigation-bar__right { 
    max-width: 50%; 
    width: 27%; 
    text-align: right; 
} 
.navigation-bar__center { 
    width: 46%; 
    text-align: center; 
    line-height: 44px; 
    font-size: 17px; 
    font-weight: 500; 
} 
.navigation-bar__title { 
    line-height: 44px; 
    font-size: 17px; 
    font-weight: 500; 
    color: #1f1f21; 
    margin: 0; 
    padding: 0; 
    overflow: visible; 
} 
.navigation-bar__center:first-child:last-child { 
    width: 100%; 
} 

.toolbar-button, 
.toolbar-button--outline, 
.toolbar-button--quiet { 
    font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; 
    -webkit-font-smoothing: antialiased; 
    -moz-osx-font-smoothing: grayscale; 
    font-weight: 400; 
    font-size: 17px; 
    padding: 4px 10px; 
    letter-spacing: 0; 
    color: #1284ff; 
    text-shadow: 0 1px none; 
    vertical-align: baseline; 
    background-color: rgba(0,0,0,0); 
    -webkit-border-radius: 2px; 
    border-radius: 2px; 
    border: 1px solid transparent; 
    font-weight: 400; 
    font-size: 17px; 
    -webkit-transition: none; 
    -moz-transition: none; 
    -o-transition: none; 
    transition: none; 
    vertical-align: middle; 
} 
.toolbar-button:active, 
.toolbar-button--outline:active, 
.toolbar-button--quiet:active { 
    background-color: rgba(0,0,0,0); 
    -webkit-transition: none; 
    -moz-transition: none; 
    -o-transition: none; 
    transition: none; 
    opacity: 0.2; 
} 
.toolbar-button:disabled { 
    opacity: 0.3; 
    cursor: default; 
    pointer-events: none; 
} 
.toolbar-button:focus, 
.toolbar-button--outline:focus, 
.toolbar-button--quiet:focus { 
    outline: 0; 
    -webkit-transition: none; 
    -moz-transition: none; 
    -o-transition: none; 
    transition: none; 
} 
.toolbar-button:hover, 
.toolbar-button--outline:hover, 
.toolbar-button--quiet:hover { 
    -webkit-transition: none; 
    -moz-transition: none; 
    -o-transition: none; 
    transition: none; 
} 
.toolbar-button--outline { 
    border: 1px solid #1284ff; 
    margin: auto 8px; 
    padding-left: 6px; 
    padding-right: 6px; 
} 
    </style> 
    </head> 
    <body ng-controller="AppController"> 

     <!-- Page content --> 

<div class="navigation-bar navigation-bar--transparent"> 
    <div class="navigation-bar__left"> 
    <span class="toolbar-button--quiet navigation-bar__line-height"> 
     <i class="ion-navicon" style="font-size:32px; vertical-align:-6px;"></i> 
    </span> 
    </div> 
    <div class="navigation-bar__center"> 
    Navigation Bar 
    </div> 
    <div class="navigation-bar__right"> 
    <span class="toolbar-button--quiet navigation-bar__line-height">Label</span> 
    </div> 
</div> 
    </body> 
</html> 

回答

5

OnsenUI使用Ionicons。因此,为了显示它,您需要将ionicons.css文件添加到您的项目中。有两种方法可以做到这一点:

  1. 在本地包含文件。去here。然后,点击Download按钮。提取文件并将ionicons.css文件添加到您的项目中。请确保你在你的项目中遵循这个文件夹安排如下:<link rel="stylesheet" type="text/css" href="ionicons/css/ionicons.css">。否则,该图标仍然不会显示。
  2. 自动将文件包含在CDN网址中。加入这个环节在乌拉圭回合的HTML头: <link rel="stylesheet" type="text/css" href="http://code.ionicframework.com/ionicons/1.5.2/css/ionicons.min.css">

注:我测试的网站上目前的CDN网址似乎不工作。因此,现在请手动添加文件,如步骤1所示。 我也通知OnsenUI团队关于此。他们表示他们将更新网站并告知用户这一要求。

+0

这取决于您如何将OnsenUI集成到您的项目中。如果您使用* bower *,您会自动将ionicons _and_字体带入您的项目中。虽然乍一看这很方便,但实际上并不是最好的,因为你会得到这两个库的过时版本。 在撰写本评论的时候,您会收到字体真棒版本4.1.0(最近是4.4.0)和ionicons 2.0.0(最近2.0.1)。温泉UI团队应该真的考虑添加依赖到凉亭配置,而不是带来旧东西。这很容易,恕我直言,在这非关键。 – 2015-08-30 00:56:05

2

其实onsen ui允许你使用ionicons和真棒字体图标。只要您包含必要的onsns js和css,您就可以使用它们(请参阅它们的CodePen示例),但当然您也可以按照之前的建议手动添加它们。我不必在工作时使用我的应用程序。

检查文档在这里:http://onsenui.io/guide/overview.html#UsingIcons

使用字体真棒 如果图标属性的值与FA-开始,使用适当的字体真棒图标。可用图标列表可在Font Awesome网站上找到。如果icon属性没有前缀,则使用Font Awesome集合。

<ons-icon icon="fa-angle-left"></ons-icon> 

<i class="fa-angle-left"></i> (as their site suggested) it works too!! 

使用Ionicons 如果图标属性的值与离子开始,使用适当Ionicons图标。可用图标列表可在Ionicons网站上找到。

<ons-icon icon="ion-chevron-left"></ons-icon> 

要了解这些值来使用,只是去他们的网站:

http://ionicons.com/ 
http://fortawesome.github.io/Font-Awesome/icons/ 

希望这有助于!

+0

你能否请看看我的问题http://stackoverflow.com/questions/27816145/jquery-vertical-tabs-not-working-in-onsenui – 2015-01-07 10:12:34

+0

你的问题已不存在。如果您有其他问题,请告诉我。 – 2015-01-07 16:01:50