Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Web Programming > CSS > CSS Cascading Style Sheets
|
CSS Cascading Style Sheets All issues relating to Cascading Style Sheets (CSS).
Welcome to the p2p.wrox.com Forums.

You are currently viewing the CSS Cascading Style Sheets section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 5th, 2007, 10:39 AM
Authorized User
 
Join Date: May 2007
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to swifty_programmer
Default Crossbrowser DIV Height 100% problems

Hi,
New post on a realy acient subject: the DIV Height 100%.

I've managed (see code below) to have in all browser a div with width and height 100% and a nice red border of 30px without any scrollbars...
Excuse me, almost without scrollbars.

By putting the CSS3 valid proprety (box-sizing: border-box;) on the DIV you can maintain the strict DOCTYPE and calculate boxes on the "old-but-more-intuitive" way (width & height = content+padding+border+margin) => see boxing model.

With this solution you have multiple problems (and solutions: yeeey!)

1.box-sizing isn't supported by... IE.
=> solution: put a comment tag aboce the DOCTYPE tag to make IE go in Quirks mode.

2.box-sizing isn't supported by mozilla-based browsers.
=> solution: put "-moz-box-sizing: border-box" in the CSS

Now you think: haha, what's your problem.
Well on all IE versions (4 till 7) and in FF 2.0 no vertical scrollbars are showed (as supposed to) but all other browsers (Netscape 8 , Opera 9...) there is a scrollbar and you can scroll +- 30px more to the bottom than the supposed 100% heigth, and you see the bottom of the body.

here is the HTML Markup:

Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <link href="DIVStylesheet.css" rel="stylesheet" type="text/css" />
    <title>DIV Page</title>
</head>
<body>
    <form id="form1" runat="server">
        <div id="_divTest" class="TestDiv">
        <span style="color: #ffffff">Dit is een DIV </span></div>
    </form>
</body>
</html>
CSS code:

Code:
html
{
    height: 100%;
    margin: 0px;
}

body
{
    height: 100%; 
    margin: 0px;
    background-color: gray;   
}

.TestDiv
{  
    margin: 0px;
    border: solid 10px red;
    width: 100%;
    background-color: blue;
    height: 100%; /* voor IE */ 
    position: absolute;
    left: 0px;
    top: 0px;
    box-sizing: border-box; /* voor moderne browsers behalve IE */
    -moz-box-sizing: border-box; /* voor mozilla-based browsers (netscape, FF ...) */
}
in like 2 second you can paste this in a new WebApp/WebSite project and see it for yourself.

Has anyone any idea from where those differences come and how they are to be "fixed"? Thx for all help!

Grtz
Lawrence
 
Old September 6th, 2007, 04:45 AM
Authorized User
 
Join Date: May 2007
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to swifty_programmer
Default

Hi,

didn't find the answer, but doesn't realy matter cuz it's so minor.
But now I have to make the same div but with a 30px margin from the body and still show no scrollbars even while resizing.
Plz help...
Thx :)





Similar Threads
Thread Thread Starter Forum Replies Last Post
CSS 100% Height DIV Problem kwilliams CSS Cascading Style Sheets 2 August 22nd, 2007 09:55 PM
div within a div and inherting the height brettdavis4 CSS Cascading Style Sheets 1 January 23rd, 2007 09:59 AM
minimise a <div> (adjust height) crmpicco Javascript How-To 1 September 21st, 2005 01:39 AM
'Auto' height of <DIV>s anshul HTML Code Clinic 3 April 28th, 2005 09:13 AM
Change height of div element if < window height JoelJunstrom Javascript How-To 1 October 10th, 2003 09:14 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.