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

时间:2011-09-17 18:44:38

标签: 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;
}

1 个答案:

答案 0 :(得分:3)

两件事。

首先,您只需将!important添加到自己的CSS定义中即可。

其次,background-image: #eeeeee;是无效的CSS。 background-image的有效属性值为url(path/to/image.png)noneinherit

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

<style>