css - 移动 jquery 中的 div 元素中未显示背景图像

标签 css jquery-mobile

我已经使用 mobile.jquery 为移动页面设置了背景图像。到目前为止一切顺利,但是...... 我链接到 jquery css 文件的 cdn 版本,如:

<link rel="stylesheet" href="http://code.jquery.com/mobile/1.0b2/jquery.mobile-1.0b2.min.css" />

显然,此 css 文件为我的内容 div 设置了背景。当我删除此 css 文件时,背景图像会显示在我所有未设置背景的 div 中。

我不喜欢不使用这个来自 CDN 的默认 css 文件,但我怎样才能覆盖我自己的 .ui-body-c 中的背景??

这是 ui-body-c 的完整 css(来自 mobile.jquery http://code.jquery.com/mobile/1.0b2/jquery.mobile-1.0b2.min.css 的内置):

.ui-body-c
{
border-top-width: 1px;
border-right-width-value: 1px;
border-right-width-ltr-source: physical;
border-right-width-rtl-source: physical;
border-bottom-width: 1px;
border-left-width-value: 1px;
border-left-width-ltr-source: physical;
border-left-width-rtl-source: physical;
border-top-style: solid;
border-right-style-value: solid;
border-right-style-ltr-source: physical;
border-right-style-rtl-source: physical;
border-bottom-style: solid;
border-left-style-value: solid;
border-left-style-ltr-source: physical;
border-left-style-rtl-source: physical;
border-top-color: #b3b3b3;
border-right-color-value: #b3b3b3;
border-right-color-ltr-source: physical;
border-right-color-rtl-source: physical;
border-bottom-color: #b3b3b3;
border-left-color-value: #b3b3b3;
border-left-color-ltr-source: physical;
border-left-color-rtl-source: physical;
color: #333333;
text-shadow: #ffffff;
background-color: #f0f0f0;
background-repeat: repeat;
background-attachment: scroll;
background-position: 0% 0%;
background-clip: border-box;
background-origin: padding-box;
background-size: auto auto;
background-image: #eeeeee;
}

最佳答案

两件事。

首先,您可以简单地添加 !important到您自己的 CSS 定义。

第二,background-image: #eeeeee;是无效的 CSS。 background-image 的有效属性值是url(path/to/image.png) , none , 或 inherit .

在您自己的服务器上创建一个名为 overrides.css 的文件(或 anything-you-want.css),或者您可以通过添加 <style> 在页面上定义它<head> 中的元素你的 HTML 元素。在该文件(或 <style> 元素)中,添加以下内容:

.ui-body-c {
    background-image: url(path/to/image.png) !important;
}

关于css - 移动 jquery 中的 div 元素中未显示背景图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7457011/

相关文章:

css - 带复选标记的右上角三 Angular 形

android - 如何在我们的应用程序 android+phonegap+JQM 中打开 pdf 文件?

onJsAlert 不响应水龙头后的 Android webview

jQuery 手机 : Enable Word Wrap in ListViews

button - 通过 CSS 调整按钮的大小

javascript - 为什么同一个功能在不同浏览器显示不同

html - 导航栏中的错误 - 视口(viewport)顶部的间隙

javascript - 即使在使用 tabs-right 之后,Bootstrap 选项卡仍显示在顶部

javascript - 否则 rgba 不能在 javascript 中工作

javascript - jquery mobile 控制组之间的空格