Welcome to WebmasterWorld Guest from 3.80.60.248
Forum Moderators: not2easy
Fairly new to CSS. Have looked at the forum - but can't find the answer. I have also checked my CSS on the W3C CSS Validation service (no errors).
I have the CSS/HTML shown at the end of this post.
when I render this in IE7, it does what I want (i.e. I get two "blocks" with what will be a menu holder underneath it).
If I use Firefox (vers 3.01), I get the two "main" blocks separated by "white space" and the "menu bar" is at the top of the screen (and on top of the two other blocks).
I played around with moving the "menu bar" with a "top" - it does move it, but on both browsers, which is not what I want.
Any ideas?
Cheers
G
/* CSS */
/* === */
/* Outline Container */
#container {
width: 800px;
/*border: 5px solid #fff;*/
margin-left: auto;
margin-right: auto;
/*padding: 10px;*/
color: #666;
background: #CCCCCC;
}
/* Two top banners */
#headimage {
float: left;
width: 310px;
height: 160px;
padding: 0;
/*margin-bottom: 15px;*/
color: #666;
background: inherit;
}
#headtext {
float: right;
width: 400px;
height: 160px;
padding: 0;
/*margin-bottom: 15px;*/
color: #666;
background: inherit;
}
/* Horizontial Menu Bar */
#menu_container{
position:relative;
width: 800px;
height: 32px;
background:#336699 url(../images/menubar.gif) top repeat-x;
}
/*Classes */
.companyname {
font-size: 180%;
margin: 0 0 10px 0;
color:#663333;
background: inherit;
}
.clear{
clear:both;
height:1px;
overflow:hidden;
}
/* HTML */
/* ==== */
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>Blah</title>
<link rel="address bar icon" href="favicon.ico" type="image/x-icon"/>
<link rel="icon" href="favicon.ico" type="image/x-icon"/>
<link rel="SHORTCUT ICON" href="favicon.ico" type="image/x-icon"/>
<meta name="Description" content="Blah" />
<meta name="Keywords" content="Blah" />
<meta name="Distribution" content="Global" />
<meta name="Author" content="Blah" />
<meta name="Robots" content="index,follow" />
<!-- <link rel="stylesheet" href="../css/style.css" media="screen" type="text/css" /> -->
<link rel="stylesheet" href="css/style1.css" media="screen" type="text/css" />
<!-- <link rel="stylesheet" href="../css/print.css" media="print" type="text/css" /> -->
</head>
<body>
<div id = "container">
<div id="headimage">
</div> <!-- headimage -->
<div id="headtext">
</div> <!-- headtext -->
<div id="menu_container">
</div> <!-- /menu_container -->
</div> <!-- container -->
</body>
</html>
1) Don't design in IE. Design in Firefox or Opera or something decent - then fix for IE if necessary.
2) All you need to do is clear #menu_container. This works.
<!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>
<title>
</title>
<meta http-equiv="content-style-type" content="text/css" />
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<style type="text/css" media="screen">
#container {
width: 800px;
/*border: 5px solid #fff;*/
margin-left: auto;
margin-right: auto;
/*padding: 10px;*/
color: #666;
background: #ccc;
}/* Two top banners */
#headimage {
float: left;
width: 310px;
height: 160px;
padding: 0;
/*margin-bottom: 15px;*/
color: #666;
background: inherit;
}#headtext {
float: right;
width: 400px;
height: 160px;
padding: 0;
/*margin-bottom: 15px;*/
color: #666;
background: inherit;
}/* Horizontial Menu Bar */
#menu_container {
position:relative;
width: 800px;
height: 32px;
background: #369 url(../images/menubar.gif) top repeat-x;
}.clear {
clear: both;
}
</style>
</head>
<body>
<div id="container">
<div id="headimage">
HEADIMAGE
</div><div id="headtext">
HEADTEXT
</div><div id="menu_container" class="clear">
MENU_CONTAINER
</div>
</div>
<!--##########
Fairly new to CSS. Have looked at the forum - but can't find the answer. I have also checked my CSS on the W3C CSSValidation service (no errors).
when I render this in IE7, it does what I want (i.e. I get two "blocks" with what will be a menu holder underneath it).
If I use Firefox (vers 3.01), I get the two "main" blocks separated by "white space" and the "menu bar" is at the top of the screen (and on top of the two other blocks).
I played around with moving the "menu bar" with a "top" - it does move it, but on both browsers, which is not what I want.
-->
</body>
</html>
To put the bully in its place you clear the floated <div>s and it follows the rules and keeps its intended place.
W3C - Floats [w3.org] - W3C is the 'go to' resource for researching how things work.
Note: You will encounter a lot of code with 'clearing <div>s'.
<div style="clear: both;"> </div>
This sets you up for the next container. They can be handy, but are overused, IMO.