代码之家  ›  专栏  ›  技术社区  ›  eth3rnit3

引导navbar rails gem glypicon

  •  0
  • eth3rnit3  · 技术社区  · 6 年前

    我刚刚添加了 gem rails-bootstrap-navbar 对于我的rails项目,我希望能够在下拉菜单前添加一个glyphicon,使用菜单项也没有问题,但对于下拉菜单本身,在 documentation . 由于下拉列表已经是一个块,我不知道如何为其添加跨度。

    = navbar fixed: :top do
      = navbar_header brand: 'My great app', brand_link: '/home'
      = navbar_collapse do
        = navbar_group class: 'foo', id: 'menu' do
          = navbar_text 'Pick an option:'
          = navbar_item "Home", '/'
          = navbar_item "About Us", '/about-us'
          = navbar_item '/contact' do
            %span.glyphicon.glyphicon-hand-right
            Contact Us!
          = navbar_dropdown "I want an icon too :-(" do
            = navbar_item '/contact' do
            %span.glyphicon.glyphicon-hand-right
            I can easily have an icon :-)
            - if true # check if user is admin, maybe like "if current_user.try(:admin?)"
              = navbar_dropdown_divider
              = navbar_item "Admin Dashboard", '/admin'
              = navbar_item "Users", '/admin/users'
        = navbar_group align: 'right' do
          - if true # check if user is logged in, maybe like "if current_user.present?"
            = navbar_item "Log Out", '/logout'
          - else
            = navbar_item "Log In", '/login'
    

    正是我想换的部分

              = navbar_dropdown "I want an icon too :-(" do
                = navbar_item '/contact' do
                %span.glyphicon.glyphicon-hand-right
                I can easily have an icon :-)
    
    1 回复  |  直到 5 年前
        1
  •  1
  •   fool-dev    6 年前

    你试着在下面这样做

    = navbar_item "<span class='glyphicon glyphicon-user'></span> Users".html_safe, '/admin/users'
    

    我想你会帮忙的