简体   繁体   English

我的CSS文档出现在Head中,但未将任何样式绑定到元素

[英]My CSS document is present in the Head but not tying any of the styles to the element

I have a few css files that are working like a charm in the head of my default.aspx template. 我的default.aspx模板的头部中有一些CSS文件,就像魅力一样工作。 We are trying to add a Custom CSS input field from the dashboard of our website builder. 我们正在尝试从我们的网站构建器的仪表板添加自定义CSS输入字段。 It is .net and the code for the head that gets rendered server side is: 它是.net,用于呈现服务器端的头部的代码是:

<asp:Literal runat="server" ID="litCustomCSS"></asp:Literal>

The codebehind for that bit is: 该位的代码为:

if (s.ToLower().Equals("websiteid"))
{
    // check if the customCSS file exists in the proper directory
    if (System.IO.File.Exists(HttpContext.Current.Server.MapPath(ConfigurationManager.AppSettings["WebsiteImagePath"] + "/" + pageInfo.ReturnValues[s] + "/CustomCSS.css")))
    {
        litCustomCSS.Text = "<link rel='stylesheet' type='text/css' id='customCSS' src='" + ConfigurationManager.AppSettings["WebsiteImagePath"] + "/" + pageInfo.ReturnValues[s] + "/CustomCSS.css' />";
    }
}

The odd part is it works... as in the file shows up in the head of the rendered page (client-side), but doesn't appear to work. 奇怪的是它可以工作...就像文件显示在渲染页面的头部(客户端)一样,但似乎不起作用。 As in if I add a custom CSS class for body or whatever it doesn't append the styles to that element. 就像我为主体添加自定义CSS类或其他未将样式附加到该元素的类一样。 It's not visible in inspect element, but I can view the css file by itself by clicking on the link in the head. 它在inspect元素中不可见,但是我可以通过单击头部中的链接来单独查看css文件。

For instance on this site ( http://tworockguns.com/home.html ) the css line is 例如,在此网站( http://tworockguns.com/home.html )上,css行是

<link rel="stylesheet" type="text/css" id="customCSS" src="/site_data/2830/CustomCSS.css">

Which links to the css file http://www.tworockguns.com/site_data/2830/CustomCSS.css 链接到css文件的http://www.tworockguns.com/site_data/2830/CustomCSS.css

I added the CSS through the backend as: 我通过后端将CSS添加为:

.footer-bottom {
background: #111111;
color: #555;
}

Which you will see did get succesfully transfered to the css doc. 您将看到确实已成功将其转移到CSS文档。

I tried changing the charset... changing the order of the css files... and still nothing. 我尝试更改字符集...更改css文件的顺序...仍然一无所获。

Any thoughts? 有什么想法吗?

You should change the src to href and it will work. 您应该将src更改为href,它将起作用。 It does for me at least on your site. 至少在您的网站上对我有用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 combres在head元素中创建指向文件的链接,但是页面呈现没有样式或脚本 - combres creates links to files in head element but page renders with no styles or scripts 在SharePoint 2010上自定义“我的配置文件” CSS样式 - Customizing the “My Profile” CSS styles on SharePoint 2010 我的CSS主体样式不适用于登录页面 - My CSS Body styles not applying to login page 通过iText创建PDF文档时未应用某些HTML和CSS样式 - Some HTML and CSS styles not applied when creating PDF document by iText 如何检查字符串是否包含字符串数组中存在的任何元素 - How to check whether string contains any element present in the string array WPF DataGrid列不使用我的默认元素样式 - WPF DataGrid columns don't use my default element styles 如何访问 <HEAD> WinForms中使用webbrower控件的HTML文档的元素? - How to get access to the <HEAD> element of a HTML document using a webbrower control in WinForms? 将数据库绑定到Form控件时出现SQL Server错误 - SQL Server error with tying my database to Form controls 我的Configuration Manager中没有“任何CPU”选项 - I do not have a 'Any CPU' option present in my Configuration Manager ASP:NET MVC:如何在一个页面中呈现两种样式而没有任何 CSS 类重叠? - ASP:NET MVC: How can I render two styles in one page without any overlaps of CSS classes?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM