alphaquest — 2012-08-02T16:25:54-04:00 — #1
Trusting this is the right place to post this question...
I have a background image in DreamWeaver and I need the top of the image to sit at the very top of the browser in the center. It will only do one or the other (top or center but not both).
Every time I change the position to “relative” it drops the image in the browser a few pixels (therefore, not flush with the top).
Any code and/or solutions to center and keep the image at the top of the browser at the same time would be much appreciated.
markbrown4 — 2012-08-02T16:43:34-04:00 — #2
Welcome to Sitepoint
You can position a background image in both directions with background-position: xPosition yPosition;
background-position: 50% 0;
alphaquest — 2012-08-02T21:05:34-04:00 — #3
Thank you for your prompt and friendly welcome!
I have tried what you suggested, for some reason it doesn't seem to be working on my end. I must be entering the code incorrectly.
Here is what my code currently looks like (without the changes), could you show me how to correct it and also include an example of the CSS code?
Thank you! Your help is very much appreciated!
markbrown4 — 2012-08-02T21:13:12-04:00 — #4
Ok, that CSS has dreamweaver layers written all over it
If you really want to learn how to build web sites you're going to need to code the CSS by hand, each and every time.
Can you post the complete HTML / CSS of your page and we'll suggest a better way to lay it out?
There's some info in the FAQ why you need to avoid absolute positioning elements like you are.
4)Don't absolute position every element unless you have a fixed width fixed height layout that isn't going to change. Otherwise you could find yourself with a very rigid layout that is hard to manage. The question often asked in the forums is how can I put a footer under the absolute columns and the answer is you can't unless the columns are a fixed height or you want to script it).
You usually need a mixture of static (default), floated and absolute positioning in most layouts and will rarely use relative positioning.