Issues while creating custom icon for navbar in jquery mobile

橙三吉。 提交于 2019-12-23 02:57:28

问题


Thought I found a solution to the problem I had with creating custom icons for nav bar through this link

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/

But Im still having problems with it. Im not able to set the border radius to none and the icons have a dark background.


回答1:


Well the Glyphish Icons are dark in color from the designer

  • http://glyphish.com/images/demo.png

Updating the themes gives you a little more control

  • http://jsfiddle.net/p9fC5/2/

Button options my help

  • http://jquerymobile.com/demos/1.1.0/docs/buttons/buttons-options.html

HTML with themes applied

<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 is used to position the icons

.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; 
}

​



回答2:


To fix your dark background problem, you need to open the icon in Photoshop and get rid of it. There is nothing to do with jQuery.

Your icon needs to have a transparent background, if you don't want to have a dark background. Just set your icon format to PNG with Alpha channel enabled and delete the background.




回答3:


This works for me in jQuery Navbars:

in HTML, add class="ui-icon-nodisc" to where you set the data-icon

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


来源:https://stackoverflow.com/questions/11138213/issues-while-creating-custom-icon-for-navbar-in-jquery-mobile

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!