在jquery mobile中为导航栏创建自定义图标时出现问题

时间:2012-06-21 12:31:09

标签: jquery-mobile

以为我找到了解决通过此链接创建导航栏自定义图标的问题的解决方案

HTML

<div data-role="page">  
    <div data-role="content">
        <div data-role="footer" class="nav-glyphish-example">
            <div data-role="navbar" class="nav-glyphish-example" data-grid="d">
            <ul>
                <li><a href="#" id="favorite" data-icon="custom">Favorite</a></li>
                <li><a href="#" id="recent" data-icon="custom">Recent</a></li>
                <li><a href="#" id="contacts" data-icon="custom">Contacts</a></li>
                <li><a href="#" id="keypad" data-icon="custom">Keypad</a></li>
                <li><a href="#" id="voicemail" data-icon="custom">Voicemail</a></li>
            </ul>
            </div>
        </div>
     </div>
 </div> 

DEMO: http://jsfiddle.net/vh4Ca/62/

但我仍然遇到问题。 我无法将border radius设置为none,图标的背景较暗。

3 个答案:

答案 0 :(得分:1)

Glyphish Icons的设计师的颜色是深色的

更新主题可让您获得更多控制权

按钮选项我的帮助

应用主题的HTML

<div data-role="page">  
    <div data-role="content"> 
        <!-- Adding theme b -->
        <div data-role="footer" class="nav-glyphish-example" data-theme="b"> 
            <div data-role="navbar" class="nav-glyphish-example" data-grid="d"> 
            <ul> 
                <li>
                    <!-- Adding theme a -->
                    <a href="#" id="favorite" data-icon="custom" data-theme="a">Favorite</a></li> 
                <li><a href="#" id="recent" data-icon="custom">Recent</a></li> 
                <li><a href="#" id="contacts" data-icon="custom">Contacts</a></li> 
                <li><a href="#" id="keypad" data-icon="custom">Keypad</a></li> 
                <li><a href="#" id="voicemail" data-icon="custom">Voicemail</a></li> 
            </ul> 
            </div> 
        </div> 
     </div>
 </div> ​

CSS用于定位图标

.nav-glyphish-example .ui-btn .ui-btn-inner {
    padding-top: 40px !important; 
}

.nav-glyphish-example .ui-btn .ui-icon { 
    width: 45px!important; 
    height: 35px!important; 
    margin-left: -24px !important; 
    box-shadow: none!important; 
    -moz-box-shadow: none!important; 
    -webkit-box-shadow: none!important;
    -webkit-border-radius: none !important;
    border-radius: none !important; 
}

#favorite .ui-icon { 
    background-image: url(http://glyphish.com/images/demo.png);
    background-position: -345px -112px;
    background-repeat: no-repeat;
}

#recent .ui-icon { 
    background-image: url(http://glyphish.com/images/demo.png);
    background-position: -9px -61px;
    background-repeat: no-repeat; 
}

#contacts .ui-icon { 
    background-image: url(http://glyphish.com/images/demo.png);
    background-position: -9px -540px;
    background-repeat: no-repeat; 
}

#keypad .ui-icon { 
    background-image: url(http://glyphish.com/images/demo.png);
    background-position: -9px -783px;
    background-repeat: no-repeat; 
}

#voicemail .ui-icon { 
    background-image: url(http://glyphish.com/images/demo.png);
    background-position: -394px -733px;
    background-repeat: no-repeat; 
}

​

答案 1 :(得分:1)

要解决您的黑暗背景问题,您需要在Photoshop中打开图标并清除它。与jQuery无关。

如果您不想拥有深色背景,则您的图标需要具有透明背景。只需将图标格式设置为启用了Alpha通道的PNG,然后删除背景。

答案 2 :(得分:1)

这适用于jQuery Navbars:

在HTML中,将 class =“ui-icon-nodisc”添加到您设置数据图标的位置

<a href="link.html" data-icon="custom" id="linkid" data-iconshadow="false" class="ui-icon-nodisc">Diplay Information</a>