Help with CSS Positioning
I am trying to position an imag开发者_如何学Pythone over the background image, but the image will not show up. Please can you tell me what I am doing wrong.
<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;
}
The first thing that stands out is that you need hashes in front of your identifiers in your CSS...
#body {
background: url(...) no-repeat;
background-size: 100%;
}
#twitter {
background: url(...) no-repeat;
//top:10px;
//position: absolute;
}
I would also recommend using a different name from "body" on the outermost div to avoid confusion with the <body>
html tag. Its not strictly necessary, but it helps to have less to think about.
For CSS:
- if you want to reference elements by id="", you prefix your CSS rule identifier with a "#" , e.g.
#twitter { .... }
- if you want to reference elements by class="", you prefix your CSS rule identifier with a "." , e.g.
.twitter { .... }
Did you mean to put .twitter
as a class or #twitter
as an id rather than twitter
(as in a tag).
yes, as said above you need to put a #
when referring to IDs in CSS, but you also need to specify a width
and a height
for your #twitter
div, so that is will have some dimension.
精彩评论