覆盖 Jquery 移动 CSS
是否可以使用单独的自定义 css 文件覆盖已设置样式的 JQuery Mobile 元素(按钮、列表等)?
如果是这样,我将如何引用这些元素。
谢谢
Is it possible to override the already styled JQuery Mobile elements (buttons, lists etc) with a separate custom css file?
If so how would I go about referencing the elements.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
是的,您可以覆盖 jQuery mobile 中已定义的所有 css 样式,但请了解如何以良好的方式执行此操作。 jQuery 文档中的主题概述包含与您的问题相关的信息。尤其:
Yes you can override all the css styles already defined in the jQuery mobile, but take a look on how to do it in a good way. Theming overview in jQuery documentation has the information referred to your question. In particular:
我不知道有什么官方的、优雅的方法来做到这一点,但我在非 min css 文件中查找类,然后将这样的内容添加到 jquery mobile after 中包含的 .css 文件中一:
.ui-header .ui-title {margin-right:20px;margin-left:20px;}
.ui-footer .ui-title {margin-right:20px;margin-left:20px;white-space:normal;}
另外,firebug 和 dev。工具(chrome)是你的朋友 - 检查元素及其样式。
利比
I don't know of an official, elegant way to do it, but I look in non-min css file to find classes, then add things like this to a .css file included after the jquery mobile one:
.ui-header .ui-title {margin-right:20px;margin-left:20px;}
.ui-footer .ui-title {margin-right:20px;margin-left:20px;white-space:normal;}
Also, firebug and dev. tools (chrome) are your friend - examine elements and their styles.
Libby
关于在 JQM 中使用自己的风格存在一个巨大的误解,我在任何地方都发现了这一点,包括 SO。在 JQM 中使用您自己的 CSS 的技巧在于如何编写您自己的 CSS。一般来说,您必须首先指定要使用 id 覆盖 JQM CSS 的元素,然后将 JQM 类附加到该 ID。例如,要从图像链接中删除 JQM 标准链接边框 CSS,其中 #img_button_1 是为图像的锚父级提供的 ID,您可以像这样编写 CSS...
HTML...
您的覆盖 CSS。 ..
我之前用一些工作示例回答过这个问题,可以在这里找到
Jquery Mobile - 使用图像作为链接 - 蓝线下图
您可以使用相同的技术来解决所有 JQM CSS 冲突。现在您可以重新考虑使用 JQM 来实现您想要的结果,因为您知道通过在您自己的 CSS 中使用 CSS 特异性来解决这些冲突是多么简单。希望这有帮助!
There is a huge misconception about using your own styles with JQM that I have found everywhere, including SO. The trick to using your own CSS with JQM is in how you write your own CSS. In general, you must first specify the element you wish to overide the JQM CSS with an id, and then attach the JQM class to that ID. For example, to remove the JQM standard link border CSS from an image link, where #img_button_1 is the ID given to the anchor parent of the image, you would code your CSS like so...
The HTML...
Your override CSS...
I answered this before with some working examples that can be found here
Jquery Mobile - Using image as link - Blue line below image
You can use the same technique for resolving all your JQM CSS conflicts. Now you can reconsider using JQM to achieve your desired results knowing how simple it is to resolve these conflicts by using CSS specicivity in your own CSS. Hope this helps!
请务必检查每个新版本的发行说明。
关于 css 层次结构中的变化,有一些有用的内容。当然,随着每个版本的发布,这通常会变得更加稳定,但是您可能需要了解一些事情。
1.4 CSS升级文档:
http://jquerymobile.com/upgrade-guide/1.4/#override -with-custom-css
Be sure to check release notes for each new version.
There's useful stuff about what's changes in the css hierarchy. Of course this generally gets more stable with each release, but there's probably going to be something you need to know.
1.4 CSS upgrade doc:
http://jquerymobile.com/upgrade-guide/1.4/#override-with-custom-css
这是一个老问题了。有很多复杂的答案,但有一个简单且合乎逻辑的解决方案:
使用 https://jquerymobile.com/download/ 中的无主题 css
This is an old question. There are many complex answers but there is the simple and logical solution:
Use theme-less css from https://jquerymobile.com/download/