Hello
I'm making a menu bar with transparent decorations and need some help.
I am using an <li> for each tab, and am able to float them to the right, but I want to fill the empty space on the left.
I imagine two ways of doing this: (see sample code)
My problem is that I cannot get anything to automatically fill the width of the left side, while not overlapping with the floated tabs. (Overlapping becomes ugly due to transparency)
Thanks so much!
I'm making a menu bar with transparent decorations and need some help.
I am using an <li> for each tab, and am able to float them to the right, but I want to fill the empty space on the left.
I imagine two ways of doing this: (see sample code)
- Insert a <div> that fills the entire remaining width, or
- Insert a new <li> that is styled to fill the entire remaining width.
My problem is that I cannot get anything to automatically fill the width of the left side, while not overlapping with the floated tabs. (Overlapping becomes ugly due to transparency)
This is a mock-up of what I am trying to produce:
![]()
HTML:
<!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>
<title>This is a test</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<style type="text/css">
body {
}
#header {
height: 20px;
width: 600px;
margin: 0 auto;
border: 1px solid black;
}
#header ul {
/* width: 600px; */
list-style: none;
padding: 0;
margin: 0;
border: 1px solid black;
float: right;
}
#header li {
float: left; /* or can use display: inline; */
margin: 0;
padding: 0;
background: url(http://img41.imageshack.us/img41/2629/glassblack.png);
height: 20px;
}
#spacer {
background: url(http://img41.imageshack.us/img41/2629/glassblack.png);
/* how to assign width here so that the #spacer occupies the remaining horizontal space? */
/* width: 100%; ???? */
/* width: auto; ???? */
}
</style>
</head>
<body>
<div id="header">
<!-- could add a <div id="spacer"></div> here? -->
<ul>
<!-- Could add an <li id="spacer"></li> here? -->
<li>Tab 1</li>
<li>Tab 2</li>
<li>Tab 3</li>
</ul>
</div>
</body>
</html>
Thanks so much!