treehouse : what would you like to learn today?
Web Design Web Development iOS Development

CSS height and positioning for IE

  • Hi!

    This is my first post here, and I am not a professional (as I am sure a quick look at the code below would reveal). I am trying to adapt wiki software and skins to suit the needs of a project website. The site looks ok in all browsers except IE, and I was hoping that someone here could give me some tips on how the code can be adapted, or what a separate css sheet for IE could look like to achieve the same results.

    An excerpt from the css file for English language:

    /* body
    --------------------------------------------------*/
    body {
    margin:0;
    padding:0 0px;
    font-family:Lucida Grande, Lucida Sans Unicode, Helvetica, Arial, sans-serif;
    font-size:75%;
    line-height:1.6em;
    text-align:center;
    }
    body {height:100%;}
    html {height:100%;}

    /* header
    --------------------------------------------------*/
    #header {
    height:100px;
    _height:auto;
    _position:fixed;
    width:600px;
    float:right;
    padding:4px 0px 0 0px;
    }

    #header .sitelang ul {
    margin:0px;
    padding:0px;}

    #header .sitelang li {
    margin:2px 0 0 0px;
    padding:0px;
    float:left;
    font-size:1.2em;
    line-height:0.85em;
    list-style-type:none;
    white-space:nowrap;}

    #header .sitelang li a {
    padding:0px 5px 4px 5px;
    background:#444444;}

    #header .fontsize ul {
    margin:0px;
    padding:0px;}

    #header .fontsize li {
    margin:-10px 0 0 0px;
    padding:0px;
    font-size:0.8em;
    font-weight:bold;
    list-style-type:none;}

    #header .fontsize li a {
    display:block;
    margin:0px 0 0 0;
    height:2.2em;
    width:1em;
    float:left;
    line-height:1em;
    text-align:center;
    color:white;

    background:#cccccc;
    border-right:1px solid #eCeCeC;
    }

    #header .login {
    margin:0px 0px;
    width:100%;
    list-style-type:none;}

    #header .login li {
    float:right;
    margin:0px;
    padding:0px;
    padding-right:0px;
    list-style-type:none;
    white-space:nowrap;}

    #header .login ul {
    margin:0;
    padding:0;
    list-style-type:none;
    }
    #header .login li a {
    display:block;
    padding:0 5px 0px 5px;
    clear:right;
    line-height:1.6em;
    background:#444444;
    border-left:1px solid #eCeCeC;
    list-style-type:none;
    }

    #header .pactions li {float:right;}

    #header .pactions li a{
    display:block;
    padding:0 5px 1px 5px;
    color:white;
    clear:right;
    font-size:0.95em;
    background:#cccccc;
    line-height:1.7em;
    border-left:1px solid #eCeCeC;
    list-style-type:none;
    white-space:nowrap;
    }

    #header .pactions ul li {
    list-style-type:none;}


    #header .pagegroup {
    padding: 14px 0 7px;
    display: block;
    }
    #pagetitle {
    float:left;
    clear:both;
    margin:-77px 0px 0 65px;
    }

    #pagetitle h1 {
    font-size:1.1em;
    line-height:1.2em;
    font-weight:normal;
    }

    #sitelogo {
    }
    #header .sitetitle {
    font-size: 22px;
    width:600px;
    line-height:1.1em;
    padding: 60px 0 0px 0px;
    text-align: left;
    }

    /* navigation
    --------------------------------------------------*/
    #navigation {
    height:1.6em;
    line-height:1.6em;
    width:600px;
    clear:right;
    float:left;
    _line-height:0px;
    }
    #navigation ul {
    margin:0px;
    padding:0px;
    }

    #navigation li {
    float:left;
    margin:0px;
    padding:0px;
    padding-left:0px;
    list-style-type:none;
    white-space:nowrap;
    }

    #navigation .navres li {
    border-right:0px solid;
    float:right;
    margin:0px;
    padding:0px;
    padding-left:0px;
    list-style-type:none;
    white-space:nowrap;
    }

    #navigation .navlinks li a {
    display:block;
    padding:0 5px 0 5px;
    border-left:1px solid #eCeCeC;
    border-bottom:1px solid #eCeCeC;
    }

    #navigation .navres a {
    float:right;
    display:block;
    padding:0 5px 0 5px;
    background:#cccccc;
    border-left:1px solid #eCeCeC;
    border-bottom:1px solid #eCeCeC;
    }

    #navigation .navres ul {
    float:right;
    display:block;
    padding:0 0 0 0;
    background:#cccccc;
    border-left:1px solid #eCeCeC;
    border-bottom:1px solid #eCeCeC;
    }

    #navigation .navlinks, .navres, .selflink li a {
    font-size:1em;
    letter-spacing:0px;
    }
    * html #navigation a {width:1%;}


    The div classes login, pactions, sitelang and fontsize enclosed in #header, and with the div navres enclosed in navlinks. This is what the html template looks like:


    <body>
    <div id=\"container\">
    <div id=\"header\">
    <div id=\"sitelogo\" style=\"\"><!--wiki:{$SiteGroup}.{$SkinName}-SiteHeader--></div>
    <div id=\"pagetitle\"><h1>{$Titlespaced}</h1></div>
    </div>
    <div id=\"navigation\">
    <div class=\"navlinks\"><!--wiki:{$SiteGroup}.{$SkinName}-SiteNav--></div>
    </div>
    <hr class=\"low\" />
    <div id=\"content\">
    </div>
    </div>
    </body>


    Let me know if screenshots are helpful, and I will make some to post here. Hope there is a way to get the layout to work in IE as well without too much trouble.

    Cheers,
    -V
  • Some screenshots to illustrate:

    Site in MSIE 6.0
    Site in MSIE 7.0
    Site in FF 3 (as intended, almost)
  • hey - could you link to the site? or copy and paste in the code from "Veiw source" so we have the full code as its rendered?

    Thanks :D
  • Here's the code for the page as displayed:

    <!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 profile=\"http://www.w3.org/2005/10/profile\">
    <link rel='stylesheet' href='http://www.mohajareen.net/pub/skins/Blix/layout.css' type='text/css' />
    <link rel='stylesheet' href='http://www.mohajareen.net/pub/skins/Blix/color.css' type='text/css' />
    <script type=\"text/javascript\" src=\"http://www.mohajareen.net/pub/skins/Blix/javascript/jquery-1.2.1.pack.js\"></script>
    <script type=\"text/javascript\" src=\"http://www.mohajareen.net/pub/skins/Blix/javascript/Blix.js\"></script>
    <script type=\"text/javascript\" src=\"http://www.mohajareen.net/pub/skins/Blix/javascript/fontsize.js\"></script>
    <link rel='icon' type='image/png' href='http://www.mohajareen.net/pub/skins/Blix/favicon.png' />

    <!--HTMLHeader--><style type='text/css'><!--
    a.createlink { color: red; }
    #wikitext { line-height: 1.4em; }
    #wikitext sub, #wikitext sup { line-height: 0; }
    --></style>

    <title>ar_title | Reconstructing Mohajareen, Nahr al-Bared</title>
    </head>

    <body>
    <div id=\"pagecont\">

    <div id=\"container\">
    <div id=\"subcontainer\">

    <div id=\"header\";'>
    <!--PageHeaderFmt-->
    <div id=\"sitelogo\" style=\"\"><div class=\"login\" >
    <ul><li><a class='wikilink' href='http://www.mohajareen.net/pmwiki.php?n=Main.Background?action=login'>Login to edit</a>

    </li></ul></div>
    <div class=\"pactions\" >
    </div>
    <div class=\"fontsize\" >
    <ul><li><div class='larger'><a href='javascript:resizeText(1);'>+<br>A</a></div>
    </li><li><div class='smaller'><a href='javascript:resizeText(-1);'>-<br>A</a></div>
    </li></ul></div>
    <div class=\"sitelang\" >
    <ul><li><a class='wikilink' href='http://www.mohajareen.net/pmwiki.php?n=Main.Background?userlang=ar'>?????</a>
    </li></ul></div>
    <div class=\"sitetitle\" >Reconstruction of Mohajareen, Nahr al-Bared
    </div>

    </div>
    <!--/PageHeaderFmt-->
    <div id=\"pagetitle\">
    <!--PageTitleFmt-->
    <h1>en_title</h1>
    <!--/PageTitleFmt-->
    </div>
    </div>

    <div id=\"navigation\">
    <div class=\"navlinks\">
    <div class=\"navlinks\" >
    <ul><li><a class='wikilink' href='http://www.mohajareen.net/pmwiki.php?n=Main.HomePage'>Home</a>
    </li><li><a class='wikilink' href='http://www.mohajareen.net/pmwiki.php?n=Background.Background'>Background</a>
    </li><li><b class='selflink'>Project Goals</b>
    </li><li><a class='wikilink' href='http://www.mohajareen.net/pmwiki.php?n=Blog.Blog'>Newsblog</a>
    </li><li><a class='wikilink' href='http://www.mohajareen.net/pmwiki.php?n=Main.Contact'>Get Involved</a>

    </li></ul></div>

    </div>
    <div class=\"navres\">
    </div>
    </div>

    <hr class=\"low\" />
    <div id=\"content\">
    <!--PageText-->
    <div id='wikitext'>

    <h2>Project Goals</h2>
    <div style='text-align:left; float:left; width:405px; padding-right:15px; padding-bottom:5px;' >
    <div><img width='405px' src='http://www.mohajareen.net/uploads/Main/Background/modelimg.jpg' alt='' title='' /></div>
    <p><span class='imgtxt'>Test image, height should be reduced.</span>
    </p><h2>Result 1</h2>
    <p>text...
    </p></div>
    <div class='vspace'></div><div style='text-align:left; float:right; width:150px; padding-bottom:5px;' >
    <h2>Result 2</h2>
    <p>text...
    </p>
    <div class='vspace'></div><h2>Result 3</h2>

    <p>text...
    </p></div>
    <div class='vspace'></div>
    </div>

    </div>

    <hr class=\"low\" />
    <div id=\"footer\" class=\"clearfix\">
    <!--PageFooterFmt-->
    <div class='lfloat' >
    <p><span style='font-size:83%'>This page was last updated on 24.11., at CET</span>

    </p></div>
    <div class='rfloat' >
    <p><span style='font-size:83%'><a class='urllink' href='http://pmwiki.com/Skins/Blix' rel='nofollow'>Blix-1.0.0</a></span>, <span style='font-size:83%'><a class='urllink' href='http://pmwiki.com/wiki/PmWiki/ChangeLog' rel='nofollow'>pmwiki-2.2.0-beta62</a></span>
    </p></div>

    <!--/PageFooterFmt-->
    </div>
    </div>
    <div id=\"subcontent\">
    <!--PageRightFmt-->

    <form class='wikisearch' action='http://www.mohajareen.net/pmwiki.php?n=Main.Background' method='get'><input type='hidden' name='n' value='Main.Background' /><input type='hidden' name='action' value='search' /><input type='text' name='q' value='search'
    class='inputbox searchbox' size='40' /><input type='submit'
    class='inputbutton searchbutton' value='Go' /></form>
    <p class='sidehead'> Donor
    </p><ul><li><a class='wikilink' href='http://www.mohajareen.net/pmwiki.php?n=Main.EC'>linktext</a>
    </li></ul><p class='vspace sidehead'> Implemented by
    </p><ul><li><a class='wikilink' href='http://www.mohajareen.net/pmwiki.php?n=Main.NRC'>linktext</a>
    </li><li><a class='wikilink' href='http://www.mohajareen.net/pmwiki.php?n=Main.Nabaa'>linktext</a>
    </li></ul><p class='vspace sidehead'> Contributors
    </p><ul><li><a class='wikilink' href='http://www.mohajareen.net/pmwiki.php?n=Main.NRC'>&bull;&nbsp;Test1</a>
    </li><li><a class='wikilink' href='http://www.mohajareen.net/pmwiki.php?n=Main.NRC'>&bull;&nbsp;Test2</a>
    </li></ul><p class='vspace sidehead'> Where is Mohajareen?
    </p><div><a class='wikilink' href='http://www.mohajareen.net/pmwiki.php?n=Main.NRC'><img src='http://localhost/Mohajareen_local/uploads/mapsm2.jpg' alt='' title='' /></a></div>
    <p class='vspace sidehead'> Useful Links
    </p><ul><li><a target='_blank' class='urllink' href='http://www.lebanon-support.org' rel='nofollow'>&bull;&nbsp;Lebanon Support</a>

    </li><li><a target='_blank' class='urllink' href='http://www.internal-displacement.org/countries/lebanon' rel='nofollow'>&bull;&nbsp;IDMC on Lebanon</a>
    </li><li><a class='wikilink' href='http://www.mohajareen.net/pmwiki.php?n=Main.NRC'>&bull;&nbsp;Link 3</a>
    </li><li><a class='wikilink' href='http://www.mohajareen.net/pmwiki.php?n=Main.NRC'>&bull;&nbsp;Link 4</a>
    </li></ul><p class='vspace' style='text-align: right;'> <span style='font-size:83%'><a class='wikilink' href='http://www.mohajareen.net/pmwiki.php?n=Site.SideBar?action=edit'>edit SideBar</a></span>
    </p>
    <p class='vspace'><span style='font-size:83%'>mohajareen.net © NRC (Norwegian Refugee Council) 2008</span>
    </p>

    <!--/PageRightFmt-->
    </div>

    </div>

    <div class=\"left column\"><div id=\"leftcol\"></div></div>
    <div class=\"right column\"><div id=\"rightcol\"></div></div>

    </div>
    </body>
    </html>
  • I would say, that you are probably going to start having problems because of the ammount of code you have.

    For example


    <title>ar_title | Reconstructing Mohajareen, Nahr al-Bared</title>

    </head>

    <body>
    <div id=\"pagecont\">

    <div id=\"container\">
    <div id=\"subcontainer\">

    <div id=\"header\";'>
    <!--PageHeaderFmt-->
    <div id=\"sitelogo\" style=\"\"><div class=\"login\" >


    you open 5 divs before you get to the header, personally I would change it to be like this:


    <title>ar_title | Reconstructing Mohajareen, Nahr al-Bared</title>

    </head>

    <body>
    <div id=\"pagecont\"> <!-- as the wrapper -->

    <h1>
    <!--PageHeaderFmt-->


    DIV's are great, its true, but other elements are just as good. Firstly you can style your <body> and <html> tags, then you can use a single wrapper for the whole site.

    You could even use your html/body tags as the wrapping elements - although it works ok in FF, IE says no... :cry: so don't :)

    Now im not sure if you want your nav bar on the right as high as that, but you can style your whole nav bar within the "ul" tags and create it as a list. This is because the UL tag is rendered the same as a DIV - a block element.

    I would use the H1 tag for your sites main header, this also renderes like a DIV because it is also a block element. This means you can use it like you would use a div, but without the need for another div!

    Problems mostly happen when code gets too heavy. The more code you have, the more chance there is for something not to work across the browsers - then when you have that problem, tring to fight your way through pages of code to make it work is a real battle. Because of the nature of CSS the problem might not even origionate from the place you are seeing it manifest, cause major hairloss for you :)

    personally I would recode, styling what is there first and adding divs when needed. Here are some helpful links to give you an idea about what elements are what :)

    Block Elements
    Inline Elements

    I hope that helps as a starter...