2015-07-21 59 views
0

我知道有很多这样的问题,但似乎没有任何工作。我有一个内容页面存储在一个文件夹'注册',其CSS文件存储在另一个文件夹'StyleSheets'。我简单地将CSS链接拖放到内容页面的头部部分。它仍然不起作用。CSS文件没有链接到HTML页面

CSS文件:

.unmaintable { 
     width: 1000px; 
     text-align:left; 
     background-color:chocolate; 
    } 
    .unmaintable1 { 
     width:250px; 
     text-align:center; 
    } 
    .unmaintable2 { 
     width:250px; 
    } 
     .unmaintable3 { 
      width:250px; 
    } 
     .unmaintable4 { 
     width:250px; 
    } 
     .imagebuttons { 
      width:94px; 
      height:70px; 
    } 

内容页:

<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="Reg-step1.aspx.cs" Inherits="Registration_Reg_step1" %> 

    <asp:Content ID="Content1" ContentPlaceHolderID="Title" Runat="Server"> 
    Step 1 
    </asp:Content> 
<asp:Content ID="Content2" ContentPlaceHolderID="head" Runat="Server"> 
<link href="../StyleSheets/ContentPage.css" rel="stylesheet" /> 
</asp:Content> 
<asp:Content ID="Content3" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server"> 
<table cellpadding="0" cellspacing="0" class="unmaintable"> 
       <tr> 
        <td class="unmaintable1">&nbsp;</td> 
        <td class="unmaintable2">&nbsp;</td> 
        <td class="unmaintable3">&nbsp;</td> 
        <td class="unmaintable4">&nbsp;</td> 
       </tr> 
       <tr> 
        <td class="unmaintable1">&nbsp;</td> 
        <td class="unmaintable2">&nbsp;</td> 
        <td class="unmaintable3">&nbsp;</td> 
        <td class="unmaintable4">&nbsp;</td> 
       </tr> 
    </table> 
    </asp:Content> 

这里有一个有趣的事情是,我得到了想要的结果,在设计模式(使用的Visual Studio 2013),但是当我运行它( IE11,CHROME,FIREFOX)它什么都不做。

+0

是的,我很抱歉它是'StyleSheets'。我也编辑了这个问题。 – RelatedRhymes

+0

加上一个讽刺CSS类名 – zeroef

+0

@MrLister - 我一直在这样工作。这张桌子显示出相当不错的,当我把一个空的桌子wthout任何border.I有一个母版页和页脚,所以它很容易请参阅表格 – RelatedRhymes

回答

0

我在您的html中看不到<head>标记。格式应该是

<!DOCTYPE html> 
<html> 
<head> 
<link href='~/css/My.css' rel='stylesheet' /> 
</head> 
<body> 
//some html 
</body> 
</html> 

我相信你可能会把css放在错误的地方。

+0

这是一个带有主页面的aspx页面,OP没有显示我们可以假定头部被定义的主页面。 –

+0

其他方式他的CSS链接设置错误我相信 – code

+0

编辑为''而不是“” – code

0
<link href="../StyleSheets/ContentPage.css" rel="stylesheet" /> 

此更改

<link href="~/StyleSheets/ContentPage.css" rel="stylesheet" /> 

那么它应该工作根据需要

+0

不,它不起作用。它带走了整个表现在 – RelatedRhymes

+0

把完整的URL在href,并确保你的CSS文件名是否正确 –

0

请使用: <link href="~/StyleSheets/ContentPage.css" rel="stylesheet" type="text/css" media="screen" runat="server" />

意味着添加RUNAT = “服务器”,使相对路径可行

+0

我只是did.That没有做任何事情 – RelatedRhymes

0

嗯,我没有看到DOCTYPE,html,head,bo dy标签是一种有趣的,但试试这个。 ../可能表示你的CSS的错误路径。

<link href='~/css/My.css' rel='stylesheet' /> 
+0

请仔细阅读其他答案too.I已经尝试了以上和它doesn”牛逼work.It应该去一个文件夹,并在一个文件夹下找到CSS文件,并因为我拖放链接到页面上,它应该是correct.I正在使用Visual Studio 2013具有母版,并拥有所有但需要的标签加载page.This是ContentPage – RelatedRhymes