我正在尝试将图像放置在背景图像上,但图像不会显示。请告诉我我哪里做错了。
<body>
<div id="body">
<div id="twitter">
</div>
</div>
</body>
CSS
body {
background: url(...) no-repeat;
background-size: 100%;
}
twitter {
background: url(...) no-repeat;
//top:10px;
//position: absolute;
}
发布于 2011-08-20 23:42:39
突出的第一件事是,在CSS中,您需要在标识符前面使用散列...
#body {
background: url(...) no-repeat;
background-size: 100%;
}
#twitter {
background: url(...) no-repeat;
//top:10px;
//position: absolute;
}
我还建议在最外层的div中使用与"body“不同的名称,以避免与<body>
html标记混淆。严格来说,这并不是必须的,但它有助于减少思考。
对于CSS:
.twitter { .... }
发布于 2011-08-20 23:42:52
您的意思是要将.twitter
作为类,还是将#twitter
作为id而不是twitter
(如在标签中)。
发布于 2011-08-20 23:57:08
是的,如上所述,当在CSS中引用is时,你需要放置一个#
,但是你还需要为你的div指定一个width
和一个height
,这样它就会有一些维度。
https://stackoverflow.com/questions/7132796
复制相似问题