 |
|
|
| View previous topic :: View next topic |
| Author |
Message |
griebs
Joined: 05 Jul 2009 Posts: 3
|
Posted: Sun Jul 05, 2009 4:11 pm Exact positioning an image atop background/div |
|
|
|
For the life of me I cannot get a seemingly simple task to work:
I have 'bg.gif' which is 780x460 (small filesize tho). I would like it centered with a 5px border. I can do this no problem two different ways: centering a table and centering a background (in which case I think I'd have to add the border in photoshop).
The problem is that I cannot position "Image1.gif" or "Image2.gif"..etc where I want them on top of the background image without them jumping all over the place when I change monitor res.
I have tried absolute, relative positioning, padding, margin, V space, H space, even nesting Image1.gif all to no avail. The images do not move in respect to the bg as it self-centers but to the frameset.
Let me know if seeing code will help-- I've got several versions running comparatively complicated Javascripting for fading, swap image etc (work just fine) that I can cut out to get to the main code, just thought there might be a forehead smacking code you genies could come up with right away. Much obliged-- |
|
PayneLess Designs

Joined: 28 Feb 2007 Posts: 3593 Location: Biloxi, MS
|
Posted: Sun Jul 05, 2009 4:53 pm |
|
|
|
Try setting the image as the bg image of a div containter. Then set the color you want to use as the five pixel border. Something like this:
| Code: |
| <div style="width: 780px; height: 460px; border: 5px solid #0f0; background: #f00 url(bg.gif) no-repeat center scroll;"></div> |
If you need the div container also centered, then add: margin: 0 auto;
Set #f00 as your preferred bg color if you want one. Otherwise, remove the hex color code. |
|
griebs
Joined: 05 Jul 2009 Posts: 3
|
Posted: Sun Jul 05, 2009 5:17 pm |
|
|
|
That's it?! I was using dreamweaver and positioning WIS (what I saw) only WIS was not WIG.
Instead I used pure coding:
| Code: |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<div style="width: 780px; height: 460px; border: 5px solid #0f0; background: #f00 url(media/theshirtm.gif) no-repeat center scroll; margin: 0 auto;"><img src="shirt-white.gif" width="254" height="277"/></div>
</head>
<body>
</body>
</html>
|
Essentially copying what you told me and including the image source inside the div container. Thanks so much! |
|
PayneLess Designs

Joined: 28 Feb 2007 Posts: 3593 Location: Biloxi, MS
|
Posted: Sun Jul 05, 2009 6:35 pm |
|
|
|
| You're very welcome. Glad the code was what you needed. Thanks for using HTMLCodeTutorial.com. |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|
|
|
|
 |
|
|
|
|
|
|
|