引用css样式表中的元素

时间:2015-04-29 19:25:28

标签: html css

我正在教自己css和html,我创建了一个样式表,并将其分解为不同的元素(背景图像,光标等)。我在主html文件中引用整个css文件,但是当我运行应用程序时,我得到一个空白屏幕。我错过了什么?这是我的代码。首先是样式表

html, body
{
    overflow: auto;
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
}

#background
{
    background-image: url("../Assets/Graphics/background.jpg");
    background-color: #cccccc;
    background-size: 100% 100%;
    background-repeat: no-repeat;
    opacity: 0.5;
}

#mycursor
{
    cursor: url(../Assets/Graphics/cursor.cur), auto;   
}

现在是html文件:

    <!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>Destiny Saga</title>
    <link rel="stylesheet" type="text/css" href="Style/style.css" />
    <link rel="shortcut icon" type="image/x-icon" href="Assets/Graphics/title.ico" />
</head>
<body>
</body>
</html>

1 个答案:

答案 0 :(得分:0)

肯定错误的事情:

  • img元素缺少src属性
  • #mycursor选择器与id="mycursor"的元素匹配,您有id="#mycursor"
  • #background规则集与任何元素都不匹配

您可能还有其他问题(例如错误的网址)。

简而言之,HTML中没有任何内容可以创建可见效果,并且任何适用于它的样式都不会改变它。