Forum Moderators: not2easy

Message Too Old, No Replies

Trouble Floating Text Over Image

         

appage

7:00 pm on May 29, 2009 (gmt 0)

10+ Year Member



Hi, I'm a bit of a CSS newbie so bear with me please.

I have a header graphic with navigation links. I want to float some more text links over the top right corner of this image. The image uses an image map so I can't use it as background image.

I'm able to place the text where I want in the image, the problem is that it pushes the image down on the page. I want this image to be at the very top of the page and the only way it doesn't move is if I use absolute for the positioning of the text, which I don't want to use.


<div id="topnav">
<div id="links">
<p><a href="#">Home </a>¦ <a href="#">Blog</a></p>
</div>
<img src="http://www.example.com/image.jpg" width="757" height="74" /></div>


#topnav {
width: 757px;
margin-top: 0px;
margin-right: auto;
margin-bottom: 0px;
margin-left: auto;
}
#links {
position: relative;
top: 20px;
left: 0px;
width: auto;
float: right;
}

I've experimented with everything I can think of but can't seem to get it how I'd really like it.

Thanks for your time.

swa66

8:18 pm on May 29, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



the only way it doesn't move is if I use absolute for the positioning of the text, which I don't want to use.

Why not ?

appage

8:25 pm on May 29, 2009 (gmt 0)

10+ Year Member



Because I'm designing my page in Dreamweaver. I was able to adjust it in dreamweaver to look how I wanted using absolute. Then I uploaded it and viewed in FireFox and it looked totally different.

swa66

8:54 pm on May 29, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Blaming the tool ...

Maybe somebody using dreamweaver can explain how to get it working in dreamweaver, but it really is the simplest solution to use positioning.

here's what I'd do:


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>untitled</title>
<style type="text/css">
* {
margin:0;
padding:0;
}
#topnav {
width: 757px;
margin: 0px auto;
position: relative; /* to gain position */
}
#topnav ul {
position: absolute;
top: 3px; /* relative to the parent that has position */
left: 3px;
list-style: none;
}
#topnav li {
display: inline; /* or however you like it */
}
#topnav li+li {
border-left: 1px solid black;
padding-left: 5px;
}
#topnav img {
width:757px;
height:74px;
}
</style>
</head>
<body>
<div id="topnav">
<ul>
<li><a href="#">Home</a></li>
<li><a href="#">Blog</a></li>
</ul>
<img src="image.jpg" alt="required" />
</div>
</body>
</html>

I only tested the code in FF, might need help in IE. The sibling selector for one isn't supported by IE6, so that at least will degrade there unless you add something like IE7.js .

appage

9:28 pm on May 29, 2009 (gmt 0)

10+ Year Member



Thanks, that seems to work perfect. I wasn't blaming the tool, just my own lack of knowledge.

Thanks again.

appage

4:43 am on Jun 3, 2009 (gmt 0)

10+ Year Member



I decided to get rid of the lines in between the links, while this looks fine in Firefox, the words are incredibly close together in IE. I tried using word spacing but it doesn't seem to do anything. Any ideas?

swa66

9:11 am on Jun 3, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Like I said: "might need help in IE".

Not knowing where you are with the code makes it hard, but I'd try padding and/or margins (try them large) in a conditional comment targeting the IE version you're using, make it large to be sure it's obeyed (IE has mean streaks). If it doesn't obey, I'd look at the display settings, some of them cause more grief than others in legacy IE versions.

Also the li+li construct will not be supported by IE6, if you have the padding in there, only more recent versions will see that.