不同字体等正文属性有效但#mainpic
或#header
中的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>
答案 0 :(得分:0)
好的,首先:使用类而不是ID。好的CSS从来没有任何ID(除了一些非常特殊的情况)
其次,你的css中有html,所以这不起作用。
第三,你不能嵌套css选择器。而不是
.wrapper {
/* some css */
.element {
/* some css */
}
}
你必须写
.wrapper {
/* wrapper css */
}
.wrapper .element {
/* element css */
}
答案 1 :(得分:0)
在CSS代码中正确关闭所有括号,将img
标记从CSS移至HTML代码,并且不要使用无效的属性或值(&#34; center&#34;,&# 34;中心&#34;)在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;
}
&#13;
<!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>
&#13;
答案 2 :(得分:-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
NOT centre
。