html - 如何在 jQuery Mobile 中更改面板图像和颜色主题

标签 html css jquery-mobile

我一直在尝试更改面板按钮的图像和菜单的颜色,但一直没有成功。我希望面板按钮与类似于 facebook 移动应用程序上的标题的标题融为一体。此外,我希望能够更改覆盖菜单的文本颜色和背景颜色(菜单分隔线和菜单选项“新闻”)。有人可以帮我解决这个问题吗?提前致谢。

 <html>
    <head>
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <link rel="stylesheet" href="http://code.jquery.com/mobile/1.4.4/jquery.mobile-1.4.4.min.css">
        <script src="http://code.jquery.com/jquery-1.11.1.min.js"></script>
        <script src="http://code.jquery.com/mobile/1.4.4/jquery.mobile-1.4.4.min.js"></script>
    </head>
    <body>
        <div data-role="page" id="home">
        <div data-role="header"  data-position="fixed">
            <a data-controltype="panelbutton" data-role="button" data-theme="b" href="#panel_menu" data-icon="bars" data-iconpos="notext" ></a>
            <h1>My App</h1>
        </div>

        <div data-role="panel" id="panel_menu" data-position="left" data-display="overlay" data-theme="b">
            <ul data-role="listview" data-divider-theme="a" data-inset="false">
                <li data-role="list-divider" role="heading"> Menu </li>
                <li data-theme="c"> <a href="" data-transition="turn">News</a> </li>     
            </ul>
        </div>
        <div data-role="main" class="ui-content">
        </div>
        <div data-role="footer" data-position="fixed">
            <h1>Footer Text</h1>
        </div>
    </div> 
</body>
</html>

最佳答案

<body>
        <div data-role="page" id="home">
        <div data-role="header"  data-position="fixed">
            <a id="custom-button" class="custom-button" data-controltype="panelbutton" data-role="button" data-theme="b" href="#panel_menu" data-icon="bars" data-iconpos="notext" ></a>
            <h1>My App</h1>
        </div>

        <div data-role="panel" id="panel_menu" data-position="left" data-display="overlay" data-theme="b">
            <ul data-role="listview" data-divider-theme="a" data-inset="false">
                <li data-role="list-divider" role="heading"> Menu </li>
                <li data-theme="c"> <a href="" data-transition="turn">News</a> </li>     
            </ul>
        </div>
        <div data-role="main" class="ui-content">
        </div>
        <div data-role="footer" data-position="fixed">
            <h1>Footer Text</h1>
        </div>
    </div> 
    </body>

CSS:

#custom-button{
  background: transparent;
}
.custom-button{
background:transparent!important;
}

解释:

您需要编写自定义样式的每个元素都可以添加一个 id,例如 a 元素,我添加了一个自定义按钮 id。请记住 id 必须是唯一的,每页一个。添加到 id 的每个样式都会自动覆盖任何类样式。 您还可以将类添加到已经存在的一次,但使用 !important hack 来覆盖现有样式。

关于html - 如何在 jQuery Mobile 中更改面板图像和颜色主题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26901898/

相关文章:

css - 多个 jQuery Mobile 计数气泡

javascript - CSS/JavaScript 中的多列垂直滚动

javascript - 使用 anchor 标记 a 在网格中创建动态按钮

jquery - 添加 jquery 移动面板后,Google map 无法正确显示

html - 是否可以从另一个元素引用 css 属性?

html - 与其他 div 的相对和绝对创建问题

html - IE7 - 使用 div 来屏蔽选择 - 选择的高度被忽略,下拉列表的位置太高,超过文本

javascript - 单击其他 href 后,href 的 onclick 中断

javascript - Angular UI 导航栏崩溃不起作用

android - 使屏幕的窗口宽度