css 样式在发布后不起作用

标签 css publish

我有两个 CSS 类:

1.-highlightedsearchresult --> 突出显示表格中的元素,因为它们被选中

2.-visitedsearchresult --> 标记已经访问过的元素

两者都在我的 Site.css 中定义:

    .highlightedsearchresult
    {
     border: medium solid #009999 !important;
     background-color: #FFCC66 !important; /* this should overwrite the background color */
    }

   .visitedsearchresult
    {
     /* border: medium solid #FFFFFF !important;#6699CC  #cc99cc  #99CCFF*/
     background-color:  #cc99cc !important; /* this should overwrite the background color */
     }

我的问题是,在将网站发布到本地或服务器上后,我的 visitedsearchresult 没有被应用(突出显示的搜索结果样式在发布时应用正常,因此我知道它是一个不错的引用我的 Site.css)。 当我在 Visual Studio 2012 下以 Debug模式运行网站时,两种 css 类样式都按预期应用

下面是适当应用我的样式的代码:

  $('.SearchResultsTable').on('click', 'tr', function () {

        var index = this.rowIndex;
        if (index == 0) {
            return; //this is the header, do nothing
        }

        $(".highlightedsearchresult").each(function () {
            $(this).addClass('visitedsearchresult');  //if item has the highlighted class, add the visited class before we removed the selected class
            //alert("add visited class");
        });

        var state = $(this).hasClass('highlightedsearchresult');
        if (!state) {
            $(this).removeClass("visitedsearchresult"); //remove our visited class, thus the background is set as selected
            $(this).addClass("highlightedsearchresult").siblings().removeClass("highlightedsearchresult");
        }
        else {
            //alert("removing visited class");
            $(this).removeClass("visitedsearchresult"); //remove our visited class, thus the background is set as selected
        }

        var storyUrl = '@Url.Action("StoryDisplay", "DisplayStory")';
        var file = $(this).attr('SearchResultFilename'); //get filename from our custom attribute
        storyUrl += "?filename=" + file;
        $("#divdisplaystory").css("width", "74%");
        $("#divsearchresults").css("width", "25%");
        $("#divdisplaystory").show();
        $('#divdisplaystory').loadWithoutCache(storyUrl);
    });

如果有人知道为什么这种特殊风格一旦发布就不起作用,我将不胜感激。非常感谢任何帮助。

更新 我使用 Fiddler Web Debugger 查看下面发生的情况,发现在访问发布网站时出现 401:由于身份验证 header 无效,您无权查看此页面。我仍然可以使用该网站,并且我的所有其他样式都已应用。此外,我在屏幕上显示了用户名 (@User.Identity.Name),它显示的是正确的 Domain\UserName。太奇怪了。该站点禁用了匿名身份验证,并启用了 Windows 身份验证

非常感谢

最佳答案

我不确定,但有时,当我想使用 java 脚本选择一个 id 或类并在母版页中使用 content palace holder 时,标签的 id 或类在发布后更改为 ContentPlaceHolder_myID它。请查看您的源页面。 (如果您使用 ASP.NET,我的解决方案很有用)

我再说一遍,如果您使用 ASP.NET 技术,我的所有 expalins 都会用到。 如果您在 asp.net 中有母版页和内容页 (http://www.w3schools.com/aspnet/aspnet_masterpages.asp) ,并使用诸如 Lable 之类的 asp.net 标记,您的元素的 Id 将在运行元素后发生变化,并且您会在元素 id 的前缀上看到内容页面的 Id。 例如:

<%@ Master %>

<html>
<body>
<h1>Standard Header From Masterpage</h1>
<asp:ContentPlaceHolder id="CPH1" runat="server">
<asp:Label ID="lblTest" runat="server" Text="Label"></asp:Label>
</asp:ContentPlaceHolder>
</body>
</html>

运行元素后你会看到:

 <span id="CPH1_lblTest">Label</span>

label tag after compile change to span tag and it's Id change from lblTest to CPH1_lblTest.(右键单击您的网页并选择查看源代码) 现在你应该在你的 javascript 中使用 CPH1_lblTest 而不是 lblTest。

关于css 样式在发布后不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21672003/

相关文章:

html - 如何在图片右侧放置文字?

html - 我怎样才能修复这个用 twitter bootstrap 构建的布局

Python打包: What to do with auxiliary modules that I use in most of my projects

javascript - Adnetwork,广告,适用于 Windows Phone 8.1 和 10 通用,支持phonegap/cordova

asp.net - 为什么我的 asp.net mvc 发布不再工作?

c# - Visual Studio 2022 无法发布 Azure 应用服务

javascript - 如何在 Angular chart.js 中更改 Canvas 高度和宽度

css - Grafana 主题可以吗?

jquery - Iframe 垂直滚动在 iOS 移动设备中不起作用

android - 出版商,如何为不同的地区设置不同的价格(美元、欧元等)