Bootstrap图标在本地加载,但在线时不加载

Jor*_*Axe 7 css image azure twitter-bootstrap twitter-bootstrap-3

基本上我得到以下HTML:

<button class="disabled btn-primary btn" type="submit" disabled="">
   <i class="glyphicon glyphicon-ban-circle"></i>
   Log in
</button>
Run Code Online (Sandbox Code Playgroud)

在本地,图标在按钮上显示正常,但是当我在Windows Azure上运行时,我得到以下按钮,带有奇怪的外观前缀而不是图标:

在此输入图像描述 考虑到这一点,我意识到当在本地访问我的网站时,浏览器会尝试加载文件:/Content/fonts/glyphicons-halflings-regular.woff(它成功地执行),而当在线(在azure上)它将尝试在以下位置加载:/fonts/glyphicons-halflings-regular.woff

为什么它没有放置它在本地执行的/ Content前缀.

我正在使用标准的bootstrap文件,它是本地和在线运行的完全相同的网站.

我也是通过以下方式捆绑内容:

    bundles.Add(new StyleBundle("~/Content/bootstrapcss").Include(
                "~/Content/bootstrap/bootstrap.css"));
Run Code Online (Sandbox Code Playgroud)

文件结构如下所示:

在此输入图像描述

bootstrap也在寻找这样的文件:

url('../fonts/glyphicons-halflings-regular.woff') 
Run Code Online (Sandbox Code Playgroud)

所以我认为它会在Content文件夹中查找而不是root文件,因为它当前位于Content/bootstrapcss文件夹中.

Gau*_*tri 13

我们最近有类似的问题(虽然我们正在使用metroUI- http://metroui.org.ua/).基本上我们发现我们正在捆绑css文件,因此当我们在Windows Azure中部署应用程序时,没有加载任何字体.

在我们的例子中,我们有以下目录结构:

在此输入图像描述

而modern.css引用的字体就像

../fonts/iconFont.eot
Run Code Online (Sandbox Code Playgroud)

我们正在捆绑css文件,如下所示:

bundles.Add(new StyleBundle("~/Content/css").Include(
                "~/Content/css/modern.css",
                "~/Content/css/modern-responsive.css"));
Run Code Online (Sandbox Code Playgroud)

由于捆绑,应用程序/fonts在应用程序根目录中查找目录中的字体,这显然不存在.

长话短说,我们最终改变了包名:

bundles.Add(new StyleBundle("~/Content/css/metroUI").Include(
                "~/Content/css/modern.css",
                "~/Content/css/modern-responsive.css"));
Run Code Online (Sandbox Code Playgroud)

更改包名称后,事情就开始正常运行了.

  • 尝试将`〜/ Content/bootstrapcss`更改为`〜/ Content/bootstrapcss/bootstrap`,这应该会有所不同.基本上当捆绑的`bootstrapcss`成为应用程序根目录中`Content`文件夹中文件的名称,寻找`Fonts`文件夹.如果css文件引用了像`../ fonts`这样的字体,它就会超过`Content`文件夹.添加另一个名称将使css上升到"Content"文件夹,然后查找它将找到的"Fonts"文件夹. (2认同)