如何使用themeroller工作生成jquery移动自定义主题?

时间:2013-07-23 16:23:21

标签: javascript jquery-mobile jquery-mobile-themeroller

我在jquery themeroller上创建了一个自定义jquery主题并下载了它,正如说明所说,我在html文件的头部包含了以下行,我是否应该将css文件传输到我的服务器?如果是这样应该是所有文件?

<meta name="viewport" charset="UTF-8" content="width=device-width, initial-scale=1"/>
<link rel="stylesheet" href="themes/MyCustomTheme.min.css" />
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.3.1/jquery.mobile-1.3.1.min.css"/>
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script src="http://code.jquery.com/mobile/1.3.1/jquery.mobile-1.3.1.min.js"></script>

2 个答案:

答案 0 :(得分:1)

我会告诉你该怎么做但是从一开始就让我们开始,我将从jQuery Mobile 1.3.2的角度讲,同样的逻辑适用于旧版本。要使用jQuery Mobile,需要两个文件(我不算基本的jQuery):

<link rel="stylesheet" href="http://code.jquery.com/mobile/1.3.2/jquery.mobile.structure-1.3.2.min.css" /> 
<script src="http://code.jquery.com/mobile/1.3.1/jquery.mobile-1.3.1.min.css"></script> 

jQuery Mobile CSS 文件也可以拆分为主题文件和结构文件,它们可以在压缩的框架文件中找到。如果您想要使用经典的主题添加新主题,您已经知道

如果要添加新主题(或样本),则需要使用 jquery.mobile.theme-1.3.2.css 文件,将其导入主题构建器工具并添加新主题/样本。最小化主题 CSS 文件不能在此处使用,必须解压缩。

当新主题完成后,系统将提示您下载包含新主题文件的zip文件。现在我们准备实施新主题了。首先解压缩下载的文件并将其保存在某处(特别是如果您打算稍后修改它)。在那里你会找到1个 HTML 文件,2个css文件和图像目录。选择 CSS 文件(任何人都可以,但如果可能,请使用缩小的文件)并将其上传到您的服务器。

现在打开您的HTML文件并添加指向新 CSS 文件的链接(指向您服务器的链接)并将其添加到原始CSS文件之后,因为新主题也有旧的,你不需要使用structure.css文件。

但是还没有结束,从你的评论中我可以看到你已经上传了你的文件,但你无法访问它。如果您的服务器是基于Linux / Unix的,则需要为新CSS文件提供新的权限,以便可以从外部访问它们。

此行可用于为其提供正确的权限(同样适用于Linux和Unix):

sudo chmod 666 <filename>

工作示例:http://jsfiddle.net/Gajotres/PMrDn/35/

最后,您只需要这些文件:

    <link rel="stylesheet" href="http://code.jquery.com/mobile/1.3.1/jquery.mobile-1.3.1.min.css" />
    <link rel="stylesheet" href="http://socialmedia.mobilevelocity.co.uk/CS408/MySocialStream.min.css" />
    <!--<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>-->
    <script src="http://code.jquery.com/mobile/1.3.1/jquery.mobile-1.3.1.min.js"

答案 1 :(得分:0)

<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="themes/MyCustomTheme.min.css" />
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.3.2/jquery.mobile.structure-1.3.2.min.css" /> 
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script> 
<script src="http://code.jquery.com/mobile/1.3.2/jquery.mobile-1.3.2.min.js"></script> 

你刚刚错过了结构文件。您仍然可以使用CDN