我被困在一个看似相当简单的问题上:
我想设计一个我添加到我的网站的 PNG 和 iframe 帽子,用 id 标签标记。不过他们似乎并不在乎。两者都不受影响。
这是我的代码:
<!DOCTYPE html>
<html>
<head>
<style>
#test{
font-weight: bold;
}
#image1 {
max-width: 80%;
}
#mb-map {
width = 600px;
height = 500px;
}
</style>
</head>
<body>
<p id = "test">test</p>
<div id = "image1">
<img src = "link to image">
</img>
</div>
<iframe id = "mb-map"
src='link to map supposed to be embedded' />
</body>
</html>
id = "test" 的文本样式正确为粗体。
-
标签
img
只打开了标签。此外,您还缺少img
标签alt
属性。 -
这是不正确的:
#mb-map { width = 600px; height = 500px; }
这是正确的:#mb-map { width: 600px; height: 500px; }
-
为
iframe
添加封闭标记,如下所示<iframe></iframe>
-
此外,您在
head
中缺少title
标签。
正确的代码
<!DOCTYPE html>
<html>
<head>
<style>
#test {
font-weight: bold;
}
#image1 {
max-width: 80%;
}
#mb-map {
width: 600px;
height: 500px;
}
</style>
<title></title>
</head>
<body>
<p id="test">test</p>
<div id="image1">
<img src="link to image" alt="">
</div>
<iframe id="mb-map" src="link to map supposed to be embedded"></iframe>
</body>
</html>
你的#image1
不是实际的img
,但它围绕着div
。
在 CSS 中,尝试#image1 img { max-width: 80%; }
对于iframe
,您的CSS使用等号而不是冒号。使用这个:
#mb-map {
width: 600px;
height: 500px;
}