2017-09-24 155 views
-3

身体属性,如不同字体的作品,但div标签属性,如在#mainpic#header只是不工作需要帮助的CSS DIV

body { 
 
    font-family: Callibri, sans-serif; 
 
    line-height: 1.5; 
 
    padding: 0; 
 
    margin: 0; 
 
    #mainpic { 
 
    <img src="../image/cutmypic.png"; 
 
    alt="image not found"; 
 
    />background-position: "centre"; 
 
    position: absolute; 
 
    bottom: 0; 
 
    center: 0; 
 
    } 
 
} 
 

 
#header { 
 
    color: white; 
 
}
<!DOCTYPE html> 
 
<html> 
 

 
<head> 
 
    <title>My Introduction</title> 
 
    <meta charset="UTF-8"> 
 
    <meta name="viewport" content="width=device-width, initial-scale=1.0"> 
 
    <link rel="stylesheet" href="style/newcss.css" /> 
 
</head> 
 

 
<body background="image/bg.jpg"> 
 

 
    <div id=“ container”> 
 
    <div id=“ header”> 
 
     <h1>Welcome</h1> 
 
    </div> 
 
    <div id="mainpic"></div> 
 
    <div id=“ content”>/div> 
 
     <div id=“ navigation”> a link to the other web page</div> 
 

 
     <div id=“ footer”> contains your name and student number</div> 
 
    </div> 
 
</body> 
 

 
</html>

+1

用不着喊。你也可以在这里输入一个错字''也可以使用'''''''''snippet编辑器并从你的CSS中删除HTML – mplungjan

+0

'#mainpic { image not found'你不能使用HTML标签在CSS规则里面。 –

+0

1)请你可以删除大写锁定,因为它很难阅读。 2)该图片的HTML标签不属于CSS。 –

回答

-1

body { 
 
    font-family: Callibri, sans-serif; 
 
    line-height: 1.5; 
 
    padding: 0; 
 
    margin: 0; 
 
} 
 

 
#mainpic { 
 
    background-position: center; 
 
    position: absolute; 
 
    bottom: 0; 
 
    /*center:0;*/ 
 
} 
 

 
#header { 
 
    color: white; 
 
}
<body background="image/bg.jpg"> 
 

 
    <div id=“container”> 
 
    <div id=“header”> 
 
     <h1>Welcome</h1> 
 
    </div> 
 
    <div id="mainpic"></div> 
 
    <div id=“content”></div> 
 
    <div id=“navigation”> a link to the other web page</div> 
 
    <div id=“footer”> contains your name and student number</div> 
 
    </div> 
 
</body>

第一个问题是你有几个错别字。 例如,<div id = “content”>/div>

第二个问题是你不能在CSS中使用HTML标记。

第三个问题是在CSS中没有语法center

并且当您使用background-position时,您不需要使用" ",而应该写入center而不是centre

+0

请说明你改变了什么 – mplungjan

+0

@mplungjan我会的。 – zynkn

+0

@mplungjan我解释过。但我不擅长英语,所以你可能不明白我想说什么。 – zynkn

0

好的第一次:使用类而不是ID。良好的CSS从来没有任何ID(除了一些非常非常具体的情况)

其次,你的CSS中有HTML,所以这是行不通的。

第三,你不能嵌套CSS选择器。取而代之的

.wrapper { 
    /* some css */ 
    .element { 
    /* some css */ 
    } 
} 

你要好好地写

.wrapper { 
    /* wrapper css */ 
} 
.wrapper .element { 
    /* element css */ 
} 
0

关闭所有括号中的CSS代码,从CSS到HTML代码移动img标签,不要使用无效的属性或值( “中心”,“中心”)在您的CSS。

另外,您在代码中使用了大量的排印引号。你必须用普通的引号替换所有这些 - 否则将无法正常工作。

body { 
 
    font-family: Calibri, sans-serif; 
 
    line-height: 1.5; 
 
    padding: 0; 
 
    margin: 0; 
 
} 
 
#mainpic { 
 
    background-position: center; 
 
    position: absolute; 
 
    bottom: 0; 
 
} 
 
#header { 
 
    color: white; 
 
}
<!DOCTYPE html> 
 
<html> 
 

 
<head> 
 
    <title>My Introduction</title> 
 
    <meta charset="UTF-8"> 
 
    <meta name="viewport" content="width=device-width, initial-scale=1.0"> 
 
    <link rel="stylesheet" href="style/newcss.css" /> 
 
</head> 
 

 
<body background="image/bg.jpg"> 
 

 
    <div id=“ container”> 
 
    <div id=“ header”> 
 
     <h1>Welcome</h1> 
 
    </div> 
 
    <div id="mainpic"><img src="../image/cutmypic.png" ; alt="image not found" ; /></div> 
 
    <div id=“ content”></div> 
 
     <div id=“ navigation”> a link to the other web page</div> 
 

 
     <div id=“ footer”> contains your name and student number</div> 
 
    </div> 
 
</body> 
 

 
</html>

+0

感谢您的建议,但我仍然看不到我的标题字体在白色我既不能看到mainpic –

+1

的图像是坦率的:你的代码是一个完整的混乱,你必须清理它。有一件事我没有提及/见过:你在代码中使用了大量的排印引号。你必须用普通的引号替换所有这些。 – Johannes

+0

哦大声笑非常感谢你,即时通讯非常新的HTML,我们的教授告诉我们使用这些排印报价,但他们是该死的问题。 –