【问题标题】:Apply Jquery Mobile ThemeRoller's theme to MVC4 Mobile Application将 Jquery Mobile ThemeRoller 的主题应用到 MVC4 移动应用程序
【发布时间】:2014-11-17 13:53:05
【问题描述】:

使用 Visual Studio 2013,我刚刚创建了一个 MVC4 移动应用程序。但是我不确定如何将 jquery mobile themeroller 主题应用到它。

我确实用我的自定义主题替换了现有的主题 css。它似乎根本不起作用。

找到下面的代码:

        bundles.Add(new StyleBundle("~/Content/css").Include("~/Content/site.css"));

        bundles.Add(new StyleBundle("~/Content/mobilecss").Include("~/Content/jquery.mobile*"));

        bundles.Add(new StyleBundle("~/Content/themes/base/css").Include(
                    "~/Content/themes/base/jquery.ui.core.css",
                    "~/Content/themes/base/jquery.ui.resizable.css",
                    "~/Content/themes/base/jquery.ui.selectable.css",
                    "~/Content/themes/base/jquery.ui.accordion.css",
                    "~/Content/themes/base/jquery.ui.autocomplete.css",
                    "~/Content/themes/base/jquery.ui.button.css",
                    "~/Content/themes/base/jquery.ui.dialog.css",
                    "~/Content/themes/base/jquery.ui.slider.css",
                    "~/Content/themes/base/jquery.ui.tabs.css",
                    "~/Content/themes/base/jquery.ui.datepicker.css",
                    "~/Content/themes/base/jquery.ui.progressbar.css",
                    "~/Content/themes/base/jquery.ui.theme.css" /*custom theme file*/));

<head->
    <meta charset="utf-8" />
    <title>@ViewBag.Title</title>
    <meta name="viewport" content="width=device-width" />
    <link href="~/favicon.ico" rel="shortcut icon" type="image/x-icon" />
    @Styles.Render("~/Content/mobileCss", "~/Content/css")
    @Scripts.Render("~/bundles/modernizr")  
</head->

我在这里错过了什么?

更新:

不知何故,我无法覆盖使用主题滚轮创建的自定义主题。我没有尝试如下直接添加对文件的引用。

<link rel="stylesheet" href="~/Content/jquery/jquery.mobile.theme-1.4.3.min.css" /> <!-- custom theme -->
<link rel="stylesheet" href="~/Content/jquery/jquery.mobile.icons.min.css" /> <!-- custom theme icon file -->
<link rel="stylesheet" href="~/Content/jquery.mobile-1.2.0.min.css" />
<link rel="stylesheet" href="~/Content/jquery.mobile.structure-1.2.0.min.css" />

在此之后我添加 JS 文件。当我添加 data-theme 属性以使用值“a”或“b”或“c”进行控制时,我得到默认颜色,而不是我在 themeroller 中在线的颜色。

【问题讨论】:

  • 我猜你忘记包含 jquery.mobile.structure.css
  • @Omar 谢谢,你能告诉我应该把结构文件放在哪里以及如何放置吗?
  • 在您的自定义主题之前加载它,您的主题取决于它。
  • bundles.Add(new StyleBundle("~/Content/mobilecss").Include("~/Content/jquery.mobile*"));此行引用内容文件夹中的所有文件,并在 _layout 页面中引用它 @Styles.Render("~/Content/mobileCss", "~/Content/css") .... 错了吗?
  • 在jquery-ui css和js之后加载JQM主题,会冲突。

标签: jquery css asp.net-mvc-4 jquery-mobile jquery-mobile-themeroller


【解决方案1】:

您实际上还没有渲染您的主题包。您仍在渲染默认的site.css。换行:

@Styles.Render("~/Content/mobileCss", "~/Content/css")

收件人:

@Styles.Render("~/Content/mobileCss", "~/Content/themes/base/css")

【讨论】:

  • 克里斯,是的,它现在可以与主题一起使用,但是仍然缺少背景颜色和图标之类的东西。捆绑包中有 2 个文件,theme-css 和 icon-css。我想在哪里添加 icon-css 文件?
猜你喜欢
  • 2012-09-04
  • 2013-05-29
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-05-31
  • 1970-01-01
  • 1970-01-01
  • 2014-02-05
相关资源
最近更新 更多