代码之家  ›  专栏  ›  技术社区  ›  Aaron M

仅在VisualStudioDesigner中使用CSS

  •  0
  • Aaron M  · 技术社区  · 16 年前

    我正在VisualStudio2008中开发一个Web应用程序。由于某些原因,CSS只能在VisualStudio中正常工作。我可以在页面的设计视图中看到CSS。当我在localhost上查看页面时,没有应用CSS。这只是我正在处理的一个非常简单的示例。只有2页,母版页和默认页。

    这是母版页。

    <head runat="server">
    <title>Foobar My Title</title>      
    <asp:ContentPlaceHolder ID="head" runat="server">
    </asp:ContentPlaceHolder>
    <link id="stylemain" href="Content/Style/main.css" rel="stylesheet" type="text/css"/> 
    </head>
    <body>
    
    <form id="form1" runat="server">
    <table border="1">
        <tr>          
        <td><a href="Default.aspx" class="topContent">Foobar</a></td>
        </tr>
        <tr>
        </tr>
        <tr>
        <td>test</td>        
        </tr>
    </table>  
    </form>
    </body>
    </html>
    

    这是我的CSS

    .topContent {
    text-align: right;
    background-color: #600;
    color: White;
    font-size: x-large;
    text-decoration: none;
    font-weight: bold;
    padding: 10px;
    height: 50px;
    

    }

    3 回复  |  直到 14 年前
        1
  •  2
  •   Nick Craver    16 年前

    您的CSS可能位于错误的相对路径。若要修复,请将链接更改为应用程序相对样式,如下所示:

    <link id="stylemain" href="~/Content/Style/main.css" rel="stylesheet" type="text/css"/> 
    

    母版页将正确解决此问题,无需 runat="server"

        2
  •  0
  •   Aaron M    16 年前

    问题是IIS7我没有检查静态内容,当我设置它

        3
  •  0
  •   Matt Brunell    16 年前

    你最近更改过CSS文件吗?可能浏览器缓存中有旧版本的CSS文件。清除浏览器缓存,看看这是否解决了问题。

    推荐文章