2

我正在尝试在我的 jquery 移动网站中添加自定义主题。

我访问了主题滚轮网站,我设计了一个主题,然后我下载了一个 zip 文件。

里面有一个主题文件夹和一个index.html。在主题文件夹中有一个图像文件夹2 个 CSS 文件

1) customTheme.css

2) customTheme.min.css

我将 2) 复制粘贴到我的项目文件夹中。

然后在我的项目中我这样做:

<head>
    <meta charset="utf-8">
    <title>CEID</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="customTheme.min.css" />
    <link rel="stylesheet" href="http://code.jquery.com/mobile/1.3.1/jquery.mobile.structure-1.3.1.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>
    <link rel="stylesheet" href="custom.css" />
</head> 

它应该工作正常吗?我在这里做错了什么?

主题不行。。

我正在设计的看起来像这样:

在此处输入图像描述

我得到的看起来像这样:

在此处输入图像描述

我的 html 看起来像这样:

<head>
    <meta charset="utf-8">
    <title>CEID</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="themes/CustomTheme.min.css" />
    <link rel="stylesheet" href="http://code.jquery.com/mobile/1.3.1/jquery.mobile.structure-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>
</head> 

我使用的自定义 CSS :

/* Home page banner */
h2#banner {
    background:transparent url(images/banner.png) no-repeat left 10px;
    width:220px;
    height:250px;
    margin:-10px auto -150px auto;
    text-indent:-9999px;
}
/* Home page banner landscape */
.landscape h2#banner {
    background:transparent url(../img/banner/banner-landscape.jpg) no-repeat left 10px;
    width:480px;
    height:290px;
    margin:-10px auto -175px auto;
    text-indent:-9999px;
}

.ui-listview .ui-li-icon {
     max-height: 32px !important;
      max-width: 32px !important; 
}

/* Home page icons */
.ui-li-icon {
    top:0.4em !important;
}
/* Make room for icons */
.ui-li-has-icon .ui-btn-inner a.ui-link-inherit, .ui-li-static.ui-li-has-icon {
    padding-left:47px;
}

我的 html 正文:

<body> 

<div data-role="page" id="home">
    <div data-role="header">
    </div>
    <div data-role="content">

        <h2 id="banner">CEID Mobile</h2>

        <div class="menu_list">
            <ul data-inset="true" data-role="listview">
                <li><a href="information.html"><img src="images/info.png" alt="Information" class="ui-li-icon">Πληροφορίες</a></li>
                <li><a href="staff.html"><img src="images/staff.png" alt="Staff" class="ui-li-icon">Προσωπικό</a></li>
                <li><a href="research.html"><img src="images/research.png" alt="Research" class="ui-li-icon">Έρευνα</a></li>
                <li><a href="undergraduates.html"><img src="images/undergraduates.png" alt="undergraduates" class="ui-li-icon">Προπτυχιακά</a></li>
                <li><a href="metaptyxiaka.html"><img src="images/graduates.png" alt="Graduates" class="ui-li-icon">Μεταπτυχιακά</a></li>
                <li><a href="students.html"><img src="images/students.png" alt="Students" class="ui-li-icon">Φοιτητές</a></li>
                <li><a href="news.html"><img src="images/news.png" alt="News" class="ui-li-icon">Ανακοινώσεις</a></li>
            </ul>       
        </div>

        <div class="menu_list">
            <ul data-inset="true" data-role="listview">
                <li><a href="http://www.ceid.upatras.gr"><img src="images/info.png" alt="Information" class="ui-li-icon">Μεταφορά στον Ιστότοπο</a></li>
            </ul>       
        </div>


    </div>
</div>

</body>
4

1 回答 1

4

Your example won't work, take a look what you have :

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

There are 3 different css files. First one is your custom theme, second one is only structure css file (everything else), and last one is complete jQuery Mobile css file. Currently your last css file (complete one) is overriding custom css theme.

To solve your problem change everything to:

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

Or even better remove jquery.mobile-1.3.1.min.css and use only:

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

What you need to understand, jQuery Mobile have 3 available css files. jquery.mobile-1.3.1.min.css should be used alone because it hase css for themes and structure. If you have custom themes then you only need to use custom theme css file and jquery.mobile.structure-1.3.1.min.css.

EDIT :

Don't forget that you also need to add data-theme to your page DIV container:

<div data-role="page" id="home" data-theme="b">

or you can add it only to your header, content and footer DIV's but I would advise you to add it to page DIV.

于 2013-06-05T09:50:08.453 回答