Welcome to Dream.In.Code
Become an Expert!

Join 150,425 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 1,081 people online right now. Registration is fast and FREE... Join Now!




Cross-Browser Layout Problems

 
Reply to this topicStart new topic

Cross-Browser Layout Problems, Cross-Browser Layout

Realedazed
16 Mar, 2008 - 02:45 PM
Post #1

New D.I.C Head
*

Joined: 13 Mar, 2008
Posts: 26


My Contributions
EDIT: I found the exact same tutorial on this site. I'm going to follow that one and see where I went wrong. Thanks.

Ok, I followed this tutorial that I found on the net.

I'm trying it out for myself. I colored the boxes with random colors and everything looked cool in the beginning. But when I started adding text and more styling, everything fell apart in FF. It looks decent in IE, though. I thought eveything was basically the same between the source code of the tutorial and mine - except I left out the float: right menu box. That was getting on my nerves with overlapping.

I uploaded it, if you want to see it: here (Sorry for the blinding colors.)

In FF the Header Div (purple) seems to be floating, while in IE its flush to the top. And then I want the Menu right under that.

In FF, the Foot DIV (green) is hanging out of the Containter DIV(red). And I want that to be flush to the bottom of the container. I actually made the Contents DIV(aqua) longer by playing around with all of the heights, so that it'll push it down to the bottom. Butis there a better way to do it?

I think that's about it.

Code is here:
CODE
<html>
   <head>
      <title>TITLE</title>
<style type="text/css" media="screen">

body{
margin: 0;
padding: 0;
font: 85% arial, hevetica, sans-serif;
text-align: center;
color: #000;
background-color: #D6D6D6;
}
    
#container{
margin: 1em auto;
width: 650px;
height:510px;
text-align: left;
background-color: red;
border: 1px solid black;
}
    
#header { background-color: fuchsia; }
#mainnav { background-color: green;}

#mainnav ul {
margin: 0 0 0 20px;
padding: 0;
list-style-type: none;
border-left: 1px solid #C4C769;
}
    
#mainnav li {
display: inline;
padding: 0 10px;
border-right: 1px solid #C4C769;
}
    
#mainnav li a {
text-decoration: none;
color: #272900;
}
    
#mainnav li a:hover {
text-decoration: none;
color: #fff;
background-color: #272900;
}
/*    
#menu{
float: right;
width: 180px;
background-color: yellow;
} styles the container */

    
#contents{
margin-right: 40px;
margin-left: 40px;
margin-top: 20px;
margin-bottom: 20px;
background-color: aqua;
height: 380px;
padding: 10x;
}
    
#footer{
clear: both;
height: 20px;
background-color: lime;
}
</style>

<div id="container">
    <div id="header"><h1>Welcome this Site!</h1></div>

    <div id="mainnav">
        <ul>
            <li><a href="#">Section 1</a></li>
            <li><a href="#">Section 2</a></li>
            <li><a href="#">Section 3</a></li>
            <li><a href="#">Section 4</a></li>
            <li><a href="#">Section 5</a></li>
            <li><a href="#">Section 6</a></li>
            <li><a href="#">Section 7</a></li>
        </ul>
    </div>

    <div id="contents">blah blah</div>

    <div id="footer">(c)EMB, Inc 2008 and beyond</div>

</div>


This post has been edited by Realedazed: 16 Mar, 2008 - 06:17 PM
User is offlineProfile CardPM
+Quote Post

thehat
RE: Cross-Browser Layout Problems
17 Mar, 2008 - 06:54 AM
Post #2

D.I.C Head
Group Icon

Joined: 28 Feb, 2008
Posts: 217


Dream Kudos: 100
My Contributions
The problem with your header was caused by you not setting any rules for the h1 tag. A specific h1 rule fixes that:

css

header h1 {
margin:0;
padding:0;
}


To keep your footer at the bottom you need to set a few rules. In the container rules, set positioning to relative. This allows any elements within the contain that have absolute positioning to calculate their position based on the container, not the page.

css

position:relative;


In the footer rules, set positioning to absolute and bottom to 0px. This sticks your footer to the bottom or it's first positioned parent (the container). Because this absolute positioning takes your footer div out of the flow of the document, it will no longer inherit it's width, you will have to set it manually.

css

position:absolute;
bottom:0px;
width:650px;


Hope that helps smile.gif
User is offlineProfile CardPM
+Quote Post

Realedazed
RE: Cross-Browser Layout Problems
18 Mar, 2008 - 01:23 PM
Post #3

New D.I.C Head
*

Joined: 13 Mar, 2008
Posts: 26


My Contributions
QUOTE


Hope that helps smile.gif


Very much! Thanks
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/9/09 08:41PM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month