Results 1 to 6 of 6

Thread: Firefox ignoring breaks and margins

  1. #1
    Join Date
    Aug 2010
    Location
    Jacksonville, FL
    Posts
    85
    Thanks
    31
    Thanked 0 Times in 0 Posts

    Default Firefox ignoring breaks and margins

    I'm writing code for a home page in IE7. When viewed in IE8 or Firefox, the breaks are totally ignored. Is there a way to resolve this issue?

    http://jaxpubliclibrary.org/welcome-new2.html

    If you look at the above URL in IE7, the page looks like I want it to look. If you look at it in Firefox or IE8, it does not have a space between the calendar at the top and the Featured Programs. It is as if Firefox and IE8 are ignoring
    <br />
    <p>&nbsp;</p>
    margins

    Thank you for your help, Elbee

  2. #2
    Join Date
    Jul 2008
    Location
    Derbyshire, UK
    Posts
    3,033
    Thanks
    25
    Thanked 599 Times in 575 Posts
    Blog Entries
    40

    Default

    You have 2 choices;

    The dirty fix - this uses conditional comments to serve more empty <p> and <br/> tags to IE8+ and non-IE browsers, until the gap gets big enough to suit;
    PHP Code:
    <!--[if lt IE 7]>
    <
    br/>&nbsp;
    <
    p>&nbsp;</p>
    <![endif]-->

    <![if !
    IE]>
    <
    br/>&nbsp;
    <
    p>&nbsp;</p>
    <![endif]> 
    OR, the clean fix;
    Remove the empty <p> and <br/> tags used as spacers and add a bottom margin on the div that contains your calendar instead. This should create a gap that all browsers play nicely with.
    Focus on Function Web Design
    Fast Edit (A flat file, PHP web page editor & CMS. Small, FREE, no database!) | Fast Edit BE (Snippet Manager) (Web content editor for multiple editable regions!) | Fast Apps

  3. The Following User Says Thank You to Beverleyh For This Useful Post:

    Elbee (08-19-2010)

  4. #3
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    I don't think any of that will help here because the problem is due to float. In IE 7 and earlier a float is considered to have the native height of its content. This is non-standard though. All others treat a float as though it has no intrinsic height until cleared or some other style is applied to it to give it intrinsic height.

    For example, here:

    Code:
            <div style="width:200px;padding:0;margin:0px;float:left;border:1px;">
                    <span style="font-weight:bolder;padding-left:40px;padding-right:46px;margin-left:0px;margin-right:0px;margin-top:2px;background-color:#7096C6;color:#ffffff;font-size:larger;">Events This Month</span>
                    <div id="eventstinycal" class="eventstinycal"></div>
                </div></div>  
            <script type="text/javascript" src="http://jplcalendar.coj.net/evanced/lib/tinycal.asp?ln=ALL"></script>            
            </div>
            <br />
    If you add a clear:

    Code:
            <div style="width:200px;padding:0;margin:0px;float:left;border:1px;">
                    <span style="font-weight:bolder;padding-left:40px;padding-right:46px;margin-left:0px;margin-right:0px;margin-top:2px;background-color:#7096C6;color:#ffffff;font-size:larger;">Events This Month</span>
                    <div id="eventstinycal" class="eventstinycal"></div>
                </div></div>         
            <script type="text/javascript" src="http://jplcalendar.coj.net/evanced/lib/tinycal.asp?ln=ALL"></script>            
            </div><div style="clear:left;"></div>
            <br />
    Then the content height of the float will be used in the layout, and the br will work.

    Without the clear the br still works, its just that it's too high up in the layout to be noticed.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  5. #4
    Join Date
    Jul 2008
    Location
    Derbyshire, UK
    Posts
    3,033
    Thanks
    25
    Thanked 599 Times in 575 Posts
    Blog Entries
    40

    Default

    In IE 7 and earlier a float is considered to have the native height of its content. This is non-standard though. All others treat a float as though it has no intrinsic height until cleared or some other style is applied to it to give it intrinsic height.
    I didnt know that - thanks for clearing things up for me.
    Focus on Function Web Design
    Fast Edit (A flat file, PHP web page editor & CMS. Small, FREE, no database!) | Fast Edit BE (Snippet Manager) (Web content editor for multiple editable regions!) | Fast Apps

  6. #5
    Join Date
    Aug 2010
    Location
    Jacksonville, FL
    Posts
    85
    Thanks
    31
    Thanked 0 Times in 0 Posts

    Default

    It worked great! <div style="clear:left;"></div>

    Thank you so much!

  7. #6
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Quote Originally Posted by Beverleyh View Post
    I didnt know that - thanks for clearing things up for me.
    Quote Originally Posted by Elbee View Post
    It worked great! <div style="clear:left;"></div>

    Thank you so much!
    Your welcome. There are other ways, but unless there is some reason why a clear cannot be used, it's the most reliable.

    Just to clarify about IE 7. I think that it may be more compliant with the standard on float than IE 6, but that at least at times it still (as obviously here it did) exhibits this older type behavior in regard to float.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •