CSS不应用于Visual Studio 2012设计器? [英] CSS not being applied in Visual Studio 2012 designer?

查看:189
本文介绍了CSS不应用于Visual Studio 2012设计器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些css,它在我的CSS文件内不应用于我的设计器在Visual Studio,但应用于页面时,我发布它。这个问题大大减慢了网站的开发速度,因为我试图拿起CSS我走...



这里是一个CSS的样例:

  .header {
background-color:#ccc;
border-bottom:1px solid#666;
color:#222;
display:block;
font-size:20px;
font-weight:bold;
padding:100px 100px 100px 100px;
text-align:center;
text-decoration:none;
text-shadow:0px 1px 0px #fff;
background-image:-webkit-gradient(linear,left top,left bottom,
from(#ccc),to(#999));
}

我在页面上应用CSS:

 < header> 
< asp:Label ID =lblQuestionrunat =serverFont-Bold =TrueFont-Size =16ptText =您的问题在这里...CssClass =header ;< / asp:Label>
< / header>

我将CSS添加到页面:

 < link rel =stylesheettype =text / csshref =mycss.cssmedia =only screen and(max-width:480px)/> 

我对CSS很新,所以我希望有人能告诉我这样做是停止Visual Studio在设计器中正确渲染CSS ...



此外,如果我把我的CSS标签直接放在页面中,



样式工作示例:

pre> < style>
.header {
background-color:#ccc;
border-bottom:1px solid#666;
color:#222;
display:block;
font-size:20px;
font-weight:bold;
padding:100px 100px 100px 100px;
text-align:center;
text-decoration:none;
text-shadow:0px 1px 0px #fff;
background-image:-webkit-gradient(linear,left top,left bottom,from(#ccc),to(#999));
}
< / style>

感谢

解决方案

我建议看看Jeff Widmer的博客文章,为什么Visual Studio不能解析我的CSS类名?



基本上,站点相对路径不受Visual Studio支持。这是为什么intellisense不工作的javascript的相同的原因。



他提供此问题的修正:

 < link href =/ content / default.css =stylesheettype =text / css/> 
<%if(false){%>
< link href =../../ content / default.css =stylesheettype =text / css/>
<%}%>

更新:



媒体元素在css的链接标记中。它不会出现VS知道什么标签是,因此不尝试解析网址。



在这种情况下,css文件与页面在同一个文件夹中,因此它可以工作。但是,如果css文件被移动到另一个文件夹,那么它会停止工作,上面的修复将解决问题。


I have some css, which when inside my CSS file isn't applied to my designer in Visual Studio, but is applied to the page when I publish it. This issue is slowing down site development massively as I'm trying to pick up CSS as I go...

Here's a sample bit of CSS:

.header {
    background-color: #ccc;
    border-bottom: 1px solid #666;
    color: #222;
    display: block;
    font-size: 20px;
    font-weight: bold;
    padding: 100px 100px 100px 100px;
    text-align: center;
    text-decoration: none;
        text-shadow: 0px 1px 0px #fff;
    background-image: -webkit-gradient(linear, left top, left bottom, 
                                       from(#ccc), to(#999));
}

Me applying the CSS on the page:

<header>
    <asp:Label ID="lblQuestion" runat="server" Font-Bold="True" Font-Size="16pt" Text="Your question goes here..." CssClass="header"></asp:Label>
</header>

Me adding the CSS to the page:

<link rel="stylesheet" type="text/css" href="mycss.css" media="only screen and (max-width: 480px)" />

I'm pretty new to CSS, so I'm hoping someone can tell me what I'm doing that is stopping Visual Studio rendering the CSS properly in the designer...

Also, if I put my CSS tags directly in the page then it works, but I'd much rather keep my CSS out in it's own file, where it can be reused.

Example style working:

<style>
    .header {
        background-color: #ccc;
        border-bottom: 1px solid #666;
        color: #222;
        display: block;
        font-size: 20px;
        font-weight: bold;
        padding: 100px 100px 100px 100px;
        text-align: center;
        text-decoration: none;
        text-shadow: 0px 1px 0px #fff;
        background-image: -webkit-gradient(linear, left top, left bottom, from(#ccc), to(#999));
    }
</style>

Thanks

解决方案

I suggest taking a look at Jeff Widmer's blog post, Why does Visual Studio not resolve my CSS class names?

Basically, site relative path's aren't supported by Visual Studio. It is the same reason why intellisense doesn't work for javascript.

He offers a fix for this issue:

<link href="/content/default.css" rel="stylesheet" type="text/css" />
    <% if (false) {%>
        <link href="../../content/default.css" rel="stylesheet" type="text/css" />
    <% } %>

UPDATE:

The problem here was the media element in the link tag for the css. It doesn't appear that VS knows what that tag is and thus doesn't try to resolve the url.

In this case, the css file is in the same folder as the page, so it would work. But, if the css file is moved into another folder, then it would stop working and the fix above would solve the issue.

这篇关于CSS不应用于Visual Studio 2012设计器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆