Click to See Complete Forum and Search --> : [RESOLVED] problem positioning image at bottom
rdcody
06-17-2007, 01:24 PM
Hey All,
I'm pretty new to CSS (three weeks), and I'm having trouble trying to position
an image at the bottom of my leftnav div.
Here's a link to the test page...
http://www.buffalosoftware.net/newtest4.htm
Here is the image I am trying to use...
<a href="http://www.lunarpages.com/id/buffsoft" onmouseover="window.status='http://www.lunarpages.com';return true" onMouseOut="window.status='';return true">
<img style="border: none" src="http://www.lunarpages.com/banners/images/static_125x40_01.gif" alt="Lunarpages.com Web Hosting" /></a>
When I get it at the bottom using - position: absolute; - then I can't get
it inside the leftnav div...When I get it inside the div, then I can't get it to
go to the bottom.
I don't know...I'm about to give up and forget it.
Thanks in advance for any help with this,
Ron
WebJoel
06-17-2007, 02:14 PM
the only way you can "absolute-position" an image inside of anything is to make the container have "position:relative;". This 'seizes control' over the starting point of "0,0" (left-top and top-left).
<div style="width:200px; height:400px; border:1px solid gray; position:relative; padding-bottom:110px;">
this is the relative-positioned DIV
<img alt="This is the image" src="#" style="width:200px; height: 100px; background-color:blue; position:absolute; left:0; bottom:0;" />
</div><!-- end "container" -->
Note that "position absolute" is 'out of the document flow' and if it is 'inside' of a relative-positioned container, the content of the container will over-write the image unless you give a padding equal-to or slightly greater than the height of the image. Here, the image is 100px tall, so the padding-bottom of the container DIV is 110px (giving you a nice 10-px 'pad' between bottom-most text and image.).
Ordinarily you'd not give an image a 'background-color' but I wanted to show in color ("blue"), where the image is.
p.s., -don't give up... for the greater part, there is little that can be envisioned that cannot be created to some measure or another using CSS. -It is really quite versatile.
rdcody
06-17-2007, 02:44 PM
Hey WebJoel,
If I change the leftnav div from float: left; to position:relative, then the page
gets screwed up. Do I need to place another div inside the leftnav div to
accomplish this...if so how can I line it up?
WebJoel
06-17-2007, 02:47 PM
Hey WebJoel,
If I change the leftnav div from float: left; to position:relative, then the page
gets screwed up. Do I need to place another div inside the leftnav div to
accomplish this...if so how can I line it up? Do both, float:left; if it needs to be, and "position:relative;". I think that this would work. Here, 'relative' is not really 'positioning' anything (there are not left or right position coordinates given), you are merely setting-up that container to accept an absolute-positioned element to it's 0,0 corner.
back:
I just tested this, -works fine using both.
rdcody
06-17-2007, 03:00 PM
Like this...
#leftnav {
float:left;
position:relative;
overflow: hidden;
margin: 10px 0px 0px 12px;
width: 170px;
height: 96.4%;
text-align: center;
background-color: #808080;
border: 2px solid #9CB1C2;
background-image: url(images/leftnav.gif);
background-repeat: repeat-x;
background-position: top;
}
rdcody
06-17-2007, 03:19 PM
WebJoel...
ok, I think the problem is now naming the two images (classes) correctly..
is it as simple as this?
.imageone {
}
.imagetwo {
}
may seem like a dumb question, but I still can't get it to work.
thanks
rdcody
06-17-2007, 04:28 PM
Trial and error...I think I got it...maybe
thanks WebJoel...have a good one
rdcody
06-18-2007, 09:39 AM
OK... I finally got it! (IE was acting a little squirrely)
I put this in the leftnav div
position: relative;
float:left;
and instead of using margins
margin: 10px 0px 0px 12px;
I used this
left: 12px;
top: 10px;
Now it works good in FF and IE. :)
http://www.buffalosoftware.net/newtest6.htm
Thanks for your help WebJoel
WebJoel
06-18-2007, 12:08 PM
Looks good in IE and Fx? -Are we talking about the white 'lunarpages' image at the bottom of "left"?
See screenshots: -Works in IE, missing in Firefox... -I'd trust Firefox to show this correctly, and IE to show you what you wanted to see... :o
rdcody
06-18-2007, 12:54 PM
yes...talking about the white 'lunarpages' image at the bottom of "left"
this works in firefox 2.0.0.4 for me...this doesn't show for you?
http://www.buffalosoftware.net/newtest6.htm
WebJoel
06-18-2007, 01:07 PM
yes...talking about the white 'lunarpages' image at the bottom of "left"
this works in firefox 2.0.0.4 for me...this doesn't show for you?
http://www.buffalosoftware.net/newtest6.htm
No, it doesn't show. :( -See the screenshots? This is IE6 and Firefox 2.0.0.4 It might be something wrong with the anchor, -there is no change in the cursor to iindicate a hyperlink. I do briefly see the alt="" text, but it dissappears..
Weirdness: , -if you give the leftnav a "backgrond-color:transparent; background-image:none;", the lunar images ...appears!
grr... i've got a headache... time to take a break. :)
rdcody
06-18-2007, 01:25 PM
Well...I don't know what to tell ya
I sent the link (newtest6.htm) to my wife where she works, and it works
in firefox just fine (lunarpages image and all).
weirdness for sure :confused:
rdcody
06-18-2007, 01:43 PM
also... I seen the screen shots, I was just wondering if you
noticed I changed the original link from newtest4.htm to
newtest6.htm
WebJoel
06-18-2007, 04:58 PM
Using the webdeveloper tool in Firefox to outline your DIVs in red, and display their size(s), -here (screenshot image) is what my Firefox is seeing. Trust that I am probably not the only one... :eek:
(I'll be re-visiting this again) :)
rdcody
06-18-2007, 05:05 PM
Well...what in the world is going on. My wife just told me that in IE7 the
content is appearing again below where it orignates. How in the heck can I
fix this? There's got to be a way to place an image where I want it...
hopefully...right?
WebJoel
06-18-2007, 05:34 PM
I've only just begun to rip into this one... :D Clearly, something is 'floated' incorrectly or is not 'cleared' correctly... -It can be found. :)
WebJoel
06-18-2007, 06:49 PM
THIS works now in IE6 and Firefox 2.0.0.4. I moved the lunar img to be a 'background-image' of the anchor, -and it works! I removed an image or two from un-necessary DIV-containment. -You don't need to encapsulate an image with a DIV in order to style it... you can apply the style directly to the image with either inline-style, or class="".
WTH is the reason this wasn't working, I dunno -but I'm goning to sit back, snap-open a cold one (or three) and
not
let
it
bother me
a n y m o r e
...tonight. :D
Try this:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<meta http-equiv="Content-Style-Type" content="text/css" />
<meta http-equiv="Content-Script-Type" content="text/javascript" />
<title></title>
<script type="text/javascript"><!--
// -->
</script>
<link rel="shortcut icon" href="favicon.ico"><!-- path to your favicon -->
<style type="text/css">
/* body styles */
* {
margin: 0;
padding: 0;
}
html, body {
height: 101%; padding-bottom:10px;
}
body {
font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;
font-size: 0.8em;
background-color: #9CB1C2;
}
#wrapper {
min-height: 100%; height:100%;
width: 760px;
background-color: #F5F5F5;
border: 2px solid #74899A;
margin: 10px auto 2px auto;
}
/* font styles */
h1 {
font-size : 100%;
font-weight: bold;
text-align : center;
line-height: 300%;
color: #000078;
margin: 0px 0px 0px 0px;
}
h2 {
font-size : 100%;
font-weight: bold;
text-align : center;
color: #780000;
margin: 10px 0px 0px 0px;
}
p.mainleft {
/*font-family : sans-serif,arial,geneva,helvetica;*/
font-size : 100%;
font-weight: normal;
text-align : left;
text-indent : 20px;
color: #000000;
}
p.maincenter {
/*font-family : sans-serif,arial,geneva,helvetica;*/
font-size : 100%;
font-weight: normal;
text-align : center;
color: #000000;
}
/* space styles (1=16px) */
#sp8 {
height: 128px;
}
/* content styles */
#content {
position: relative;
text-align : center;
background-color: #F5F5F5;
/*background-color: #800000;*/
height: 96.4%;
width: 530px;
margin: 10px 25px 0px 207px;
}
* html #content {
margin: 10px 12px 0px 204px;
}
#content img {
position: absolute;
top: auto;
bottom: 25px;
left: 180px;
height: 69px;
border: 0;
}
/* navigation styles */
#leftnav {
position: relative;
float:left;
/*margin: 10px 0px 0px 12px;*/
left: 12px;
top: 10px;
width:170px;
height:96%;
text-align: center;
border: 2px solid #9CB1C2;
background: #808080 url(http://www.buffalosoftware.net/images/leftnav.gif) repeat-x;
}
/*
* html #leftnav{
margin: 10px 0px 0px 6px;
}*/
#leftnav a:link {
color: #D2D2D2;
}
#leftnav a:visited {
color: #D2D2D2;
}
#leftnav a:hover {
color: #E6E6E6;
font-weight: bold;
}
p.nav {
font-size : 100%;
font-weight: normal;
text-align : center;
line-height: 220%;
}
.imglogo {
position:relative;
margin-top:4px;
margin-left: 1px;
margin-bottom: 30px;
height: 112px;
}
.imglunar {
bottom: 6px;
left: 5px;
height: 45px;
width: 130px;
border: 0;
}
* html .imglunar{
bottom: 3px;
}
/* bottom nav styles */
#navlinks {
position: absolute;
top: auto;
bottom: 0px;
left: 0px;
background-color: #F5F5F5;
height: 10px;
width: 530px;
}
/* footer styles */
#footer {
clear: both;
width: 760px;
text-align: center;
background-color: #9CB1C2;
height: 20px;
margin: 8px auto 0 auto;
}
p.smfont{
font-size : 80%;
font-weight: normal;
text-align : center;
color: #000000;
}
</style>
<base href="http://www.buffalosoftware.net/" />
</head>
<body>
<div id="wrapper" style="position:relative;">
<div id="leftnav">
<img src="images/buffsoftlogo.gif" alt="Buffalo Software" style="margin-top:10px; width:113px; height:112px;" />
<p class="nav"><a href="index.htm">Home</a></p>
<p class="nav"><a href="products.htm">Products</a></p>
<p class="nav"><a href="contact.htm">Contact</a></p>
<a href="http://www.lunarpages.com/id/buffsoft" style="position:absolute; left:10px; bottom:20px; width:140px; height:40px; padding:0; margin:0; border:2px solid blue; background-color:gray; background-image:url(http://www.lunarpages.com/banners/images/static_125x40_01.gif)"></a>
</div>
<div id="content" style="">
<h1>Buffalo Software</h1>
<p class="mainleft">Welcome to the home of Buffalo Software. Thank you for your interest in our products. We take pride in creating innovative, high quality, and easy to use software. By the way, all of our software is FREE! So, take them for a test drive, and see what you think. Enjoy!</p>
<div id="sp8"></div>
<h1>coming soon...</h1>
<p>The PC Timer 5.0</p>
<p>The Patriot 3.0</p>
<p><a href="http://www.buffalofieldcampaign.org"><img src="images/savebuffalo.gif" alt="Save the Buffalo!" width="170" height="69"/></a></p>
<div id="navlinks"><p class="smfont"><a href="index.htm">Home</a> •
<a href="products.htm">Products</a> •
<a href="contact.htm">Contact</a></p>
</div>
</div>
<div id="footer" style="position:relative; top:4px; width:756px; padding:7px 0 2px 0; border:2px solid #f5f5f5; border-top:5px solid f5f5f5; margin-bottom:10px;"><p class="smfont">Copyright © 2007 Buffalo Software - All rights reserved. Please read our <a href="privacy.htm">Privacy Statement.</a></p></div>
</div>
</body>
</html>
rdcody
06-18-2007, 07:39 PM
Hey Joel... thanks alot - I'll look it over more closely tomorrow and try to
learn from what you did. Have a good one, Ron
WebJoel
06-19-2007, 06:58 PM
Fingers are crossed! :)
rdcody
06-21-2007, 09:34 AM
Hey Joel,
I decided to forget the lunarpages image, and just go with what I had.
I appreciate all your help. The page checks out in IE6 and 7, Fx, and Opera.
By the way, that Web Developer toolbar for Fx is pretty slick. :)
http://www.buffalosoftware.net/index.htm
Thanks, and have a good one! :D
Ron
WebJoel
06-21-2007, 11:29 AM
Very nice. :)