【问题标题】:CSS not linking to my index.htmlCSS 没有链接到我的 index.html
【发布时间】:2015-05-02 01:18:46
【问题描述】:

我是这方面的初学者,所以我很抱歉,因为我正在学习自己,所以请放慢我的脚步。我在将我的 CSS 链接到我的索引时遇到问题,我要做的就是在页面顶部制作一个黑色的部分,就像一个刚刚填充黑色的盒子。技术上的横幅区域。由于某种原因它没有链接?这是 CSS 和 HTML 代码 - 我尝试在 Chrome 和资源管理器中打开,但没有任何反应?请帮忙。

/*! normalize.css v3.0.1 | MIT License | git.io/normalize */
html {
    font-family: volkorn;
    -ms-text-size-adjust: 100%;
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
}

.top-section {
    padding: 30px 0;
    margin-bottom: 0;
    color: #000000;
    background-color: #000000;
    background-size: cover;
}

.top-section {
padding-top: 100px;
padding-bottom: 100px;
}   
<!DOCTYPE html>
<!--[if lt IE 7 ]> <html class="ie6" lang="en"> <![endif]-->
<!--[if IE 7 ]>    <html class="ie7" lang="en"> <![endif]-->
<!--[if IE 8 ]>    <html class="ie8" lang="en"> <![endif]-->
<!--[if (gte IE 9)|!(IE)]><!--> <html lang="en"> <!--<![endif]-->
<title>Upload Festival</title>  
    <head>
  
      <!-- Meta -->
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="">
    <meta name="keywords" content="">
    <meta name="author" content="">
    <meta name="googlebot" content="index,follow">
        
    <!--css-->
    <link href="css/customization.css" rel="custom" style="text/css">
  </head>
<body class="index">
<header class="top-section" role="banner"></header>
</body>
</html>

【问题讨论】:

  • 应该是这样的&lt;link type="text/css" rel="stylesheet" href="style.css"&gt;。还要确保您是手动输入的,有时当您复制粘贴时,代码会混乱。
  • 几乎每个浏览器都包含某种形式的开发者控制台;在 Windows 上,按 F12 键将打开 Chrome 的控制台,如果您安装它,将在 Firefox 中打开 Firebug。如果您检查上述控制台,我假设您会看到 404(未找到)错误。

标签: html css indexing stylesheet


【解决方案1】:

在 rel 属性和 style 属性(不存在)中,您的 CSS 链接似乎有问题。 你有这个:

<link href="css/customization.css" rel="custom" style="text/css">

应该是这样的:

<link href="css/customization.css" rel="stylesheet" type="text/css">

有关将 CSS 文件链接到您自己的网站的更多信息: http://www.w3schools.com/css/css_howto.asp

有关 LINK 标记的更多信息: http://www.w3schools.com/tags/tag_link.asp

祝你有美好的一天!

【讨论】:

    【解决方案2】:

    我是初学者,那就从简单的基本概念开始...
    使用这个作为 HTML 页面结构的模板:

    <html>
        <head>
    
            <title>Page Title</title>
            <!--Link to an external resource-->
            <link rel="stylesheet" type="text/css" href="css-folder/css-file.css">
    
        </head>
        <body>
            <header class="top-section" role="banner"></header>
        </body>
    </html>
    

    将您的style sheets 放入另一个文件中。例如:

    css-文件夹/css-file.css:

    html {
        font-family: volkorn;
        -ms-text-size-adjust: 100%;
        -webkit-text-size-adjust: 100%;
    }
    
    body {
        margin: 0;
    }
    
    .top-section {
        padding: 30px 0;
        margin-bottom: 0;
        color: #000000;
        background-color: #000000;
        background-size: cover;
    }
    
    .top-section {
        padding-top: 100px;
        padding-bottom: 100px;
    }   
    

    您现在不需要知道conditional comments、doctypes 和meta datas!
    祝你好运。

    【讨论】:

      猜你喜欢
      • 2018-07-19
      • 2017-12-05
      • 1970-01-01
      • 1970-01-01
      • 2014-05-27
      • 2015-06-14
      • 2022-01-17
      • 1970-01-01
      • 2013-08-27
      相关资源
      最近更新 更多