Forum Moderators: not2easy

Message Too Old, No Replies

Trouble with fluid header

         

lZakl

1:08 am on Jul 6, 2005 (gmt 0)

10+ Year Member



I know someone will be able to whip out an answer pretty darn quick for this one. I am trying to create a header than consists of the following.

¦Static corner logo¦ -- ¦Static center image¦ -- ¦Fluid bar 128 px high¦

Every thing I try I can get it to work in IE, but not Firefox, or the other way around. I know there must be a more simple solution that what I am trying, and quite frankly I am embarrassed to even post what I have ... Anyone willing to donate a small chunk of code for these 3 elements?

Thanks!

-- Zak

D_Blackwell

2:34 am on Jul 6, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I may not fully understand the requirements set forth, so prepare to disregard the following:

Is the whole bar {height: 128px;}, or just the fluid bar?

If you actually use borders around any or all of the sections, they may have to be accounted for.

This works, but may not suit the actual need.

<!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">
<head>
<style>
div {
height: 128px;
}
#rel {
position: relative;
}
#corner {
width: 150px; border: 1px solid #000; position: absolute; top: 0; left: 0
}
#static-center {
width: 20%; position: absolute; top: 0; left: 40%; border: 1px solid #900;
}
#fluid-bar {
border: 1px solid blue; float: right; width: 40%;
}
</style>
</head>
<body>
<div id="rel">
<div id="corner">
CORNER
</div>
<div id="static-center">
CENTER
</div>
<div id="fluid-bar">
FLUID BAR
</div>
</div>
</body>

lZakl

4:14 pm on Jul 6, 2005 (gmt 0)

10+ Year Member



D_Blackwell,

That is *almost* what I need, except the corner, center and fluid right need to run together to form a continuous looking bar all the way accross. The element sizes are as follows:

Corner image: 240 X 128
Middle image: 364 X 128
Fluid CSS bar: Fluid X 128

The corner image of course needs to be positioned 0 left and 0 top ... The center image needs to be positioned 240 left and 0 top ... THEN have the fluid bar to fill the rest of the page width.

What I am having trouble with I think is relative versus absolute positioning ... thus float for that matter. If I were to do it with a table, this is what it would look like:

<table border="0" width="100%" cellpadding="0" cellspacing="0">
<tr>
<td width=240 background="corner.gif"></td>
<td width=364 valign=top><img src="center.gif"></td>
<td bgcolor=000000>&nbsp; <!-- Just a black fluid bar--></td>
</tr>
</table>

But ... for the sake of, well ... I just don't want to use tables. ;0)

I appreciate your help!

-- Zak

D_Blackwell

11:22 pm on Jul 6, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Zak: Give this a spin - bearing in mind that I may have overlooked one or more variables important to you. This seems to work in FF, IE, and Opera. I've added borders to help keep an eye on everything, and also a couple of background-color for the same reason.

I'm overlapping #static-center and #fluid-bar, but all seems to be working and functional. Feel free to break it:))

As a separate question: Is this going to work for you at 800x600? Without regard to #fluid-bar, #corner and #static-center will overlap at low res.

<!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">
<head>
<style>
#rel {
position: relative; border: .1em dotted #000; height: 128px;
}
#corner {
width: 240px; height: 128px; position: absolute; top: 0; left: 0; border: 1px solid #000;
}
#static-center {
width: 364px; height: 128px; position: absolute; top: 0; left: 50%; margin-left: -182px; border: 1px solid #900;

background-color: #ccc
}
#fluid-bar {
height: 128px; margin-left: 50%; padding-left: 182px; border: .1em solid red; background-color: #666;
}
</style>
</head>
<body>
<div id="rel">
<div id="corner">
CORNER
</div>
<div id="static-center">
CENTERf
</div>
<div id="fluid-bar">
FLUID BAR
</div>
</div>
</body>
</html>

iamlost

1:49 am on Jul 7, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Another possible option:

CSS:


* {padding: 0; margin: 0;}

#fluid-bar {margin-left: 604px; height: 128px; background-color: #ffd;}

#corner-image {float: left; width: 240px; height: 128px; border: 0; background: #fdd url(your-corner-image.gif) no-repeat;}

#middle-image {float: left; width: 364px; height: 128px; border: 0; background: #ddf url(your-middle-image.jpg) no-repeat;}

HTML:


<div id="corner-image"></div>
<div id="middle-image"></div>
<div id="fluid-bar"></div>

D_Blackwell

2:50 am on Jul 7, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Unless I'm misunderstanding, I think that one of the tricky points is keeping the middle piece centered on the page. He'd have to give up centering the middle with this - #middle-image {float: left; width: 364px; -?-

[edited by: D_Blackwell at 2:52 am (utc) on July 7, 2005]

lZakl

2:52 am on Jul 7, 2005 (gmt 0)

10+ Year Member



D_Blackwell -- Not quite, BUT you did help me understand a whole other problem I was having! With a small tweek, your solution for this problem, solved another one entirely. *bet you somehow knew that -- like ESPN or something ...*

ialmost --

margin-left: 604px;

Pretty darn clever, and it's what did the trick and gave me the output I was looking for.

Thanks you guys!

-- Zak