tags:

views:

62

answers:

2

stemming from this question

This first image is with no overflow. The top is before I press the button, and the bottom is after.

alt text


And this image is with overflow:auto. The top is before I press the button, and the bottom is after.

alt text


What I'm looking for is the panel to look like it does in the first image before I press the button, and what it looks like in the 2nd image when I do press the button.

Here's a copy of the relevant code:

<asp:Panel ID="pnlCustomer" runat="server" style="background-color:#ccccff; width:500px; height:90%; position:relative;" BorderColor="DarkBlue" BorderWidth="2px">

...

<style>
        div.textboxArea {
            text-align:center;
            float:left;
            width:40%;
            margin-top:35px;
        }
        .textboxArea  TextBox {
            width:80%;
        }
        .centerMeVertically  div {
            position:absolute;
            top:50%;
            vertical-align:middle;
            height:30px;
            width:100%;
            margin-top:0px;
            text-align:center;
        }
        div.centerMeVertically {
            float:left;
            width:20%;
            text-align:center;
            height:60px;
            position:relative;
        }
        p {
             margin:-35px 0 0 0;
        }
        .container {
            margin-top:10px;
            margin-bottom:10px;
            overflow:auto;
        }
    </style>

    <div class="container">
        <div style="width:100%;">
            <div class="textboxArea">
                <p><asp:Label runat="server" ID="lblInfoDesc" /></p>
                <asp:TextBox ID="txtInfoDescription" runat="server" TextMode="MultiLine" Rows="3" MaxLength="500" />
            </div>

            <div class="centerMeVertically">
               <div><asp:Button ID="btnNextInfo" runat="server" Text="Next" /></div>
            </div>

            <div class="textboxArea">
                <p><asp:Label runat="server" ID="lblInfoData" /></p>
                <asp:TextBox ID="txtInfoData" runat="server" TextMode="MultiLine" Rows="3" MaxLength="500" />
            </div>
        </div>
    </div>
+2  A: 

How are you 'hiding' textboxArea? Right now, textboxArea is fully contained within container, so overflow: auto should contain it. My guess is you are hiding textboxarea via visibility: hidden, which will make it not appear, but it'll still take up space.

Instead use display: none, or, often preferred, position it off the screen via absolute positioning until you need it.

DA
why is absolute positioning preferred to display: none? display: none is most certainly my preferred way of hiding things and make more sense than pushing stuff off screen.
Sekhat
Actually, TextBoxes are being hidden in the code behind (VB) such as txtInfoData.Visible = false; How would I use the display:none on button click and switch it on another button click?
Justen
@Sekhat positioning things off screen tends to be better for accessibility and SEO purposes.
DA
@Justen MS is notorious for re-inventing common languages to make things so very very confusing. It doesn't matter what your codebehind is doing, you need to check what it's doing client-side. Using something like the FireBug in firefox, load the page and find out what specific CSS is being applied to the hidden DIV.
DA
@DA, I went to figure out why this would be better for accessibility purposes, and found "In cases where we need to hide content from a visitor but still make it available to the screenreader, we position it offscreen." from http://accessibilitytips.com/2008/03/04/positioning-content-offscreen/ though I still don't understand why this would ever be the case. Can you give an example?
Tegeril
@Tegeril a good example would be tabbed areas of content on a page. You might have 3 tabs with text in each. You'd want Google to see all the content, and anyone with a screen reader, so instead of display: none (which Google and Screen Readers may ignore) you can position it off screen. It'll still 'look' the same visually, but won't hide the content from other devices.
DA
+1  A: 

I don't see why you need overflow, or positioning, at all. Just have one outer div (with the blue background/border) and two inner divs, the second one of which starts with display: none then changes to display: block when the button is pressed.

A better was to vertically align things is with the vertical-align: middle rule, and each element set to display: inline-block - which even works in IE6!

DisgruntledGoat
you typically need overflow to ensure the container div contains floated elements.
DA
True, but there's no need to float anything in this example.
DisgruntledGoat
In the relevant code in my post, I am using float styling.
Justen