Wrox Programmer Forums
|
BOOK: Beginning CSS: Cascading Style Sheets for Web Design ISBN: 978-0-7645-7642-3
This is the forum to discuss the Wrox book Beginning CSS: Cascading Style Sheets for Web Design by Richard York; ISBN: 9780764576423
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning CSS: Cascading Style Sheets for Web Design ISBN: 978-0-7645-7642-3 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 November 17th, 2006, 05:58 PM
Vx Vx is offline
Registered User
 
Join Date: Mar 2006
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default Scrollable content with fluid layout problem

Hi,

The project I'm currently working on was initially designed for IE 6.0 exclusively but now it should support Firefox 1.5+ as well.
Among lots of different problems our team stumbled upon there is one I wanted to ask about. I am talking about Firefox behavior here.

Below is a complete simplified markup with one little script and basic styling representing the problem.

But first some comments:
Rendering mode for IE was quirks mode, so we had to add -moz-box-sizing: border-box; declaration not to recalculate the entire layout.
Code:
<html>
<head>
    <title>Scrolling problem</title>
    <style type="text/css">
        * { -moz-box-sizing: border-box; }

        html {
            width: 100%;
            height: 100%;
        }

        body {
          width: 100%;
          height: 100%;
          padding: 0px;
          margin: 0px;
        }

        td {
          width: 100%;
          height: 100%;
        }

        #myTable {
          table-layout: fixed;
          border-spacing: 0px;
          border: 3px solid red;
          width: 100%;
          height: 100%;
        }

        #myDiv {
          width: 100%; height: 100%;
          overflow: auto;
          border: 3px solid blue;
        }
     </style>

    <script type="text/javascript">
        function setContent() {
          var s = "Text to overflow Text to overflow Text to overflow Text to overflow ";
          s += "Text to overflow Text to overflow Text to overflow Text to overflow ";
          s += "Text to overflow Text to overflow Text to overflow Text to overflow ";
          s += "Text to overflow Text to overflow Text to overflow Text to overflow ";
          s += "Text to overflow Text to overflow Text to overflow Text to overflow ";          
          s += "Text to overflow Text to overflow Text to overflow Text to overflow ";
          s += "Text to overflow Text to overflow Text to overflow Text to overflow ";
          s += "Text to overflow Text to overflow Text to overflow Text to overflow ";          
          s += "Text to overflow Text to overflow Text to overflow Text to overflow ";          
          s += "Text to overflow Text to overflow Text to overflow Text to overflow ";          
          s += "Text to overflow Text to overflow Text to overflow Text to overflow ";          
          s += "Text to overflow Text to overflow Text to overflow Text to overflow ";
          s += "Text to overflow Text to overflow Text to overflow Text to overflow ";
          s += "Text to overflow Text to overflow Text to overflow Text to overflow ";
          s += "Text to overflow Text to overflow Text to overflow Text to overflow ";          

          document.getElementById("myDiv").innerHTML = s;
        }
    </script>
</head>
<body onload="setContent();">
    <table id="myTable" cellpadding="0" cellspacing="0">
      <tr>
         <td>
            <div id="myDiv">
            </div>
         </td>
      </tr>
    </table>
</body>
</html>
So we have a grid with fluid layout where width and height are set to 100%.
Inside of <td/> element lies <div/> element which dimensions are also set to 100%. This <div/> element gets its content dynamically after the page is completely rendered and have overflow property set to auto to enable scrolling of its content.

Lets assume that the ORIGINAL size of the window is small enough to cause overflow of the <div/> element's content (for example 400x300).
Initially everything is ok. We have a table with the dimensions of a viewport and <div/> element with scrollable content. The problem raises its head when we are trying to resize the window. Scroll bar of the <div/> element disappears and content of the div breaks down out of the viewport borders.
Could you explain the reason of the behavior? The question really is: why it is rendered initially in one way, but after resizing it seems to remember it shouldn't behave in such a way and reflows completely differently.

Actually the problem was solved.
We have overcome it by adding additional <div/> element inside the <td/> element. Style for this outer <div/> is set to
Code:
div.outer {
    position: relative;
    width: 100%;
    height: 100%
}
and our initial inner <div/> element got the style
Code:
div.inner {
    position: absolute;
    overflow: auto;
    top: 0px;
    right: 0px;
    bottom: 0px;
    left: 0px;        
}
But I would definitly wanted to know where the root of the problem lies. Any references to exact places in CSS specification or other authoritative sources of information are greately appriciated.

Thanks in advance







Similar Threads
Thread Thread Starter Forum Replies Last Post
Content Page for a Tree View and scrollable Textbo dotnetDeveloper ASP.NET 2.0 Basics 0 November 24th, 2008 02:34 PM
Fluid Dynamics with WPF : Error bhavsac Windows Presentation Foundation 0 July 17th, 2007 07:21 AM
Layout problem roy_mm Reporting Services 1 September 28th, 2006 03:43 PM
Page Layout Problem Spades Dreamweaver (all versions) 1 December 2nd, 2004 04:55 PM
Datalist layout Problem ManoYaka ASP.NET 1.0 and 1.1 Basics 1 February 3rd, 2004 10:40 AM





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