on IE 7, empty div will have height when width is specified

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • liketofindoutwhy

    on IE 7, empty div will have height when width is specified

    it seems that on Firefox and IE, even for standard compliance mode,
    the following code will give different result:


    <div style="border:1 px solid orange; width:300px"></div>

    on IE 7, the div will have a height of "line-height", but on Firefox
    2, the div will have zero height.

    When the width:300px is removed, then it is zero height on both IE 7
    and Firefox 2...

    any method to make them consistent? Zero height is wanted when the
    database returns empty string for within the div. Thanks very much!

  • Stanimir Stamenkov

    #2
    Re: on IE 7, empty div will have height when width is specified

    Thu, 5 Jun 2008 22:14:31 -0700 (PDT), /liketofindoutwh y/:
    it seems that on Firefox and IE, even for standard compliance mode,
    the following code will give different result:
    >
    <div style="border:1 px solid orange; width:300px"></div>
    >
    on IE 7, the div will have a height of "line-height", but on Firefox
    2, the div will have zero height.
    >
    When the width:300px is removed, then it is zero height on both IE 7
    and Firefox 2...
    >
    any method to make them consistent? Zero height is wanted when the
    database returns empty string for within the div. Thanks very much!
    Giving the DIV an explicit 'width' triggers its 'hasLayout' [1]
    property in IE which makes it render quite differently from
    standard-compliant.

    [1] http://msdn.microsoft.com/en-us/libr...76(VS.85).aspx

    --
    Stanimir

    Comment

    • dorayme

      #3
      Re: on IE 7, empty div will have height when width is specified

      In article <g2aiuu$911$1@r egistered.motza rella.org>,
      Stanimir Stamenkov <s7an10@netscap e.netwrote:

      Giving the DIV an explicit 'width' triggers its 'hasLayout' [1]
      property in IE which makes it render quite differently from
      standard-compliant.
      >
      [1] http://msdn.microsoft.com/en-us/libr...76(VS.85).aspx
      This url appears without scrollbars in Safari 2 and iCab 4.

      --
      dorayme

      Comment

      • Stanimir Stamenkov

        #4
        Re: on IE 7, empty div will have height when width is specified

        Fri, 06 Jun 2008 16:08:47 +1000, /dorayme/:
        In article <g2aiuu$911$1@r egistered.motza rella.org>,
        Stanimir Stamenkov <s7an10@netscap e.netwrote:
        >
        >Giving the DIV an explicit 'width' triggers its 'hasLayout' [1]
        >property in IE which makes it render quite differently from
        >standard-compliant.
        >>
        >[1] http://msdn.microsoft.com/en-us/libr...76(VS.85).aspx
        >
        This url appears without scrollbars in Safari 2 and iCab 4.
        I don't know how old Safari 2 and iCab 4 are and whether they could
        turn author styles off, but given the OP has IE to try with he'll be
        able to read it. I'm reading it all right using SeaMonkey 1.1.9,
        Opera 9.27, Safari 3.1.1 and Lynx 2.8.6rel.5 all on Windows.

        --
        Stanimir

        Comment

        • dorayme

          #5
          Re: on IE 7, empty div will have height when width is specified

          In article <g2alot$hjg$1@r egistered.motza rella.org>,
          Stanimir Stamenkov <s7an10@netscap e.netwrote:
          Fri, 06 Jun 2008 16:08:47 +1000, /dorayme/:
          In article <g2aiuu$911$1@r egistered.motza rella.org>,
          Stanimir Stamenkov <s7an10@netscap e.netwrote:
          This url appears without scrollbars in Safari 2 and iCab 4.
          >
          I don't know how old Safari 2 and iCab 4 are and whether they could
          turn author styles off, but given the OP has IE to try with he'll be
          able to read it. I'm reading it all right using SeaMonkey 1.1.9,
          Opera 9.27, Safari 3.1.1 and Lynx 2.8.6rel.5 all on Windows.
          iCab 4 is latest, Safari 2 is not latest but is good and would not turn
          off author styles. No problems with other browsers. I am not too curious
          given it is MS.

          --
          dorayme

          Comment

          • Jonathan N. Little

            #6
            Re: on IE 7, empty div will have height when width is specified

            liketofindoutwh y wrote:
            it seems that on Firefox and IE, even for standard compliance mode,
            the following code will give different result:
            >
            >
            <div style="border:1 px solid orange; width:300px"></div>
            >
            on IE 7, the div will have a height of "line-height", but on Firefox
            2, the div will have zero height.
            >
            When the width:300px is removed, then it is zero height on both IE 7
            and Firefox 2...
            >
            any method to make them consistent? Zero height is wanted when the
            database returns empty string for within the div. Thanks very much!
            >
            Ah hope that IE9 will be standards compliant? ;-)

            If content is from a database, just have your server side script check
            the output for content before generating the page and if there is none,
            don't generate the containing DIV.

            Not too advisable, but you could use JavaScript to scan the collection
            of DIVs and delete or hide any without content when page loads. Then
            only IE users with JavaScript disable will see the empty boxes.

            Or lastly, live with the empty boxes on IE...

            --
            Take care,

            Jonathan
            -------------------
            LITTLE WORKS STUDIO

            Comment

            • liketofindoutwhy

              #7
              Re: on IE 7, empty div will have height when width is specified

              hm, it seems like there are 2 solutions:

              1) don't show the div at all when the string is empty by using PHP
              (the border was only for debug purpose and not needed)

              2) or, this div is inside another div with width of 600px, so i can
              set this inner div to have no width, but just a margin-right of 50px
              or something like that.

              I tested both solutions and they worked in both IE 7 and Firefox 2.

              Comment

              • liketofindoutwhy

                #8
                Re: on IE 7, empty div will have height when width is specified

                so dorayme is in austalia? do you get to play a lot of sports
                there? what do you do over the weekends?

                Comment

                • dorayme

                  #9
                  Re: on IE 7, empty div will have height when width is specified

                  In article
                  <b14f11f7-f62f-480d-bdaf-069dd919c2a2@m4 5g2000hsb.googl egroups.com>,
                  liketofindoutwh y <liketofindoutw hy@gmail.comwro te:
                  so dorayme is in austalia? do you get to play a lot of sports
                  there?
                  No, I played more sport when I was in England, in bad weather and clouds
                  and snow and my right foot still has big boney top where soccer ball
                  kept hitting it and flying off at great speed, sometimes into net and me
                  pleased and team pleased and 9 out of crowd of 18 people pleased...
                  what do you do over the weekends?
                  I cry and drink a lot of tea.

                  --
                  dorayme

                  Comment

                  • liketofindoutwhy

                    #10
                    Re: on IE 7, empty div will have height when width is specified

                    On Jun 6, 3:41 pm, dorayme <doraymeRidT... @optusnet.com.a uwrote:
                    In article
                    <b14f11f7-f62f-480d-bdaf-069dd919c...@m4 5g2000hsb.googl egroups.com>,
                    >
                    liketofindoutwh y <liketofindout. ..@gmail.comwro te:
                    so dorayme is in austalia? do you get to play a lot of sports
                    there?
                    >
                    No, I played more sport when I was in England, in bad weather and clouds
                    and snow and my right foot still has big boney top where soccer ball
                    kept hitting it and flying off at great speed, sometimes into net and me
                    pleased and team pleased and 9 out of crowd of 18 people pleased...
                    >
                    what do you do over the weekends?
                    >
                    I cry and drink a lot of tea.
                    >
                    do how come you cry in the weekends? for one thing, you know CSS well
                    and seems to enjoy life.

                    Comment

                    • dorayme

                      #11
                      Re: on IE 7, empty div will have height when width is specified

                      In article
                      <5737bb2a-14ff-49f9-abde-7a20c8897be8@l6 4g2000hse.googl egroups.com>,
                      liketofindoutwh y <liketofindoutw hy@gmail.comwro te:
                      On Jun 6, 3:41 pm, dorayme wrote:
                      liketofindoutwh y wrote:
                      ....
                      what do you do over the weekends?
                      I cry and drink a lot of tea.
                      >
                      do how come you cry in the weekends? for one thing, you know CSS well
                      and seems to enjoy life.
                      Because, on the weekends, I feel like one or the other of two people who
                      enjoyed life but who were finished off by the brute, Zampanò in the
                      film, La Strada. Namely, Gelsomina and Il 'Matto'-The 'Fool'.

                      --
                      dorayme

                      Comment

                      Working...