Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

IE7 margin error on float

Featured Replies

This is my first post - apart from the introduction thread where I mentioned my dismay viewing my latest sites using IE7 on Win-PC. I develop on Mac and test in Firefox/Safari on Mac, and Firefox/IE-7 on Windows. Everything seemed to work perfectly there last week. So I signed off!

 

I went home and checked again on IE7 my Win-PC box - the one that had no CSS at all was OK but the other still had botched up margins on the logo/navigation DIV. Also the floating banner is cutting off half the logo. The homepage is different to the other pages - both have CSS problems.

 

So I need some help with this please. If anyone can view on different platforms and browsers I'd be grateful. Hopefully it is just the margin issue that's a problem.

 

www.avitalsheffer.com (mix of wordpress and passive pages)

www.avitalsheffer.com/css-js/avital10.css

 

Usually I keep my site designs fairly simple to avoid issues, but I thought I could do more with CSS menu systems and CMS. I've been playing catch-up for months (reading, testing etc) because I know I need to get more proficient with CSS and browser issues.

 

Right now my confidence as a web developer is at an all time low. Maybe I bit off more than I'm capable of?

 

This client's very specific layout and design pre-existed. Someone else had prepared Image and Flash files but wouldn't supply the originals. They had built an HTML Frames site with a mess of inline CSS - different on every page.

 

The client insisted on keeping a floating banner - that was tricky but I learned a lot. She wanted drop down menus added to the buttons - learned a lot there too - and four pages moved into Wordpress.

 

ALSO I think I need some straight advice - along the lines of what minimum testing environment (browsers) I should support AND whether I applied the wrong approach/solution?

 

Web development is just so technical these days. I don't know whether to quit or keep going. How far is the next goal post?

As you say, in IE7 the Avital Sheffer logo is cut in half. You can lower it by adding margin-top: 10px;

#col-leftHome {	float: left; width: 400px;  
margin-top: 10px;}	

Hi Anakowi,

 

I think the site is looking OK, don't be too hard on yourself.

 

Theres a couple of declarations that are probably giving you trouble with the banner:

 

height:140px; in #banner, whilst all half decent browsers read this as height (well duh), IE6 reads it as 'min-height' so it can add height to fit content if it feels like it.

 

position:fixed; is also not understood by IE6, which instead renders it as position:static; which is no help at all. To render it as position:absolute; in IE6 only, add _position:absolute; (note the underscore) underneath. this won't allow for a fixed banner in IE6, but will keep it where you want it.

 

To test stuff in IE6 download ietester from http://www.my-debugbar.com/wiki/IETester/HomePage

  • Author

Thanks for your replies.

 

Wickham - I would have to add 100px margin to top to clear - that isn't acceptable in other browser views.

 

Stevo - thanks for the IE-Tester link - it's gold. In IE6 the gap is huge as you indicated (logo not chopped).

 

After adding _position:absolute to #bannerFloatTop the view in IE7 is still chopped and now also in IE6. Nothing changes on Mac browsers.

 

Not sure how fixed or absolute is affecting position in IE6 - but it does level the field in terms of resolving the top position for the subsequent DIV #bgWrap. I've used a mess of position/margin/padding to get it to work in the first place.

 

I don't suppose there's something like Firebug for IE that highlights the box model?

 

On removing height 140px from #banner - the whole banner disappears. So I need to clarify what you mean there.

 

#bannerFloatTop - was tricky to implement. The client wanted two layers of image - the top one slides horizontally over the bottom layer. I kept trying different things until it appeared to work (in Firefox Mac - and forgot to keep testing in IE after things started to look right).

If you can't find a solution that suits all browsers, code for Firefox first (which will probably be OK for Opera, Safari, Google Chrome and possibly IE8) then code conditional comments with different top margins which only apply to IE7 and IE6.

 

I tested my margin-top: 10px in IE7 and it did work, only altering Firefox by 10px which I thought wouldn't be noticed! Since the banner was only cut in half, a 10px difference was enough to show it all.

 

For conditional comments, place this code AFTER the main stylesheet link in the head section:-

 

<!--[iF IE 7]>
<style type="text/css">
#col-leftHome { margin-top: ??px; }
</style>
<![endif]-->

<!--[iF lt IE 7]>
<style type="text/css">
#col-leftHome { margin-top: ??px; }
#bannerFloatTop { position: absolute; }
</style.
<![endif]-->

 

or whatever style and size you need. If lt IE 7 means less than IE7 for IE6, IE5.5, IE5, etc.

 

If you need a conditional comment for IE8, code another one.

 

You should be able to keep your position: fixed for modern browsers and change to position: absolute just for IE6 by inserting it in the conditional comment. It should process the positions of everything exactly the same as position: fixed but it will scroll instead of being fixed. I've just tested and it doesn't change anything except the fact that it scrolls.

  • Author

Hi Wickam,

 

Since trying Stevo's suggestions, which partially helped, I'm back to adjusting margins in combination.

 

I just tried adding 10px again to the left column DIV. Much better but not quite enough clearance - I had to apply it to the outer DIV because the top of the Flash box is also being chopped. In this case the DIV behaves differently to its nested column.

 

#bgWrap { position: relative; top: 40px; width: 1004px; height: auto; margin: 20px auto 0; padding-top: 80px; color: #444444; }

 

When I increased the value of margin-top nothing happened but when I increased the padding-top (100px) it works. Great but why?

 

I'm leaving the 10px in there because it looks better having the height difference between the 2 columns. Thanks!

 

NOW for problem # 2

 

Home page is AOK. The rest of the site is still broken.

 

In IE7 I still have the double-margin-left issue. The Logo and menu are supposed to be flush left in line with the fluid left edge of the banner image. That part works in IE6.

 

The right column (image) is supposed to scroll vertically - instead the content is pushed to the bottom (IE6) or totally gone (IE7). It's still working perfectly for all other browsers (afaik).

 

Is there a solution?

 

Oh... I discovered that IE-Tester includes a box-model view.

You've got so many stylesheets it's difficult to work out what's going on.

I can get the nav menu to line up with the left edge od Avital logo above by editing in in avital10.css:-

#navBox { margin-top: 55px; height: 184px; width: 250px; 
/*padding-left: 50px;*/}

and in homeNav.css

#navH {background:url('images/homeNavSprite.png') no-repeat; 
width:190px; height:184px; margin:0;/*0 0 0 20px;*/ padding:0;}

but it doesn't line up with the left side of the banner because that goes full width so the nav would be tight to the left window edge in my 1024*768 window which would look odd.

 

In IE7 the left vertical menu was showing shifted positions for the hover background-images and I found that I had to add margin-top: -2px to all except the first one in a conditional comment in the head section of the html page which only affects IE (I only tested IE7 but I expect all IE versions will be the same). This was inserted AFTER all the stylesheet and js file links:-

<!--[if IE]>
<style type="text/css">
#navH a.home { height: 23px; margin-top: 0px;}
#navH a.profile, #navH a.gallery, #navH a.news, #navH a.representation, #navH a.publications, #navH a.contact, #navH a.links  {height: 23px; margin-top: -2px;}
</style>
<![endif]-->

 

See the result here which looks OK in my IE7 and Firefox in 1024*768 resolution:-

http://www.wickham43.com/forumposts/anakavitalsheffer100412.html

CSS

http://www.wickham43.com/forumposts/anakavital10100412.css

http://www.wickham43.com/forumposts/anakhomeNav.css

 

The other CSS files are the same and note that I edited the image and css file urls to suit my folder structure and edited the filenames, so if you copy/paste you will have to edit those.

  • Author

Yeah, sorry about all the CSS imports. I know it's better to compress everything. I was testing so many different navigation styles lately I found it easier to separate things out.

 

BUT uh-oh I hope you didn't spend too long on that because ... :give_rose:

that's not the page with the problem now. You already helped me fix that, thanks.

 

It's the rest of the site with an alignment and image position problem only in IE7.

 

here are screen shots - Firefox vs IE7

 

Darn, you went to a lot of trouble. :blush1:

In your profile.php page the Logo and nav bar are over on the right in IE7.

 

Try editing #navbar by adding left: 0; in avital10.css

#navBar {  margin: 55px auto 0 0;  height: auto; background-image: url('../images/banner/Logo.png'); background-repeat: no-repeat; color: #660000; padding-right: 20px;  padding-bottom: 0px;  position: fixed; left: 0;}

 

It works for me.

 

I had a lot of trouble loading your page locally in IE7 although it loaded online OK and eventually I found that some png images aren't png, they are jpg saved with a png extension. Logo.png is one, I opened it in a graphics program which gave me a warning and saved it as .jpg and changed the url in the css file. There may be others, but I disabled the urls so that I could load the page locally to test.

 

In IE7 the image on the right intro.jpg which is in a position: fixed div wasn't showing until I added left: 110px;

#col-right { width: 360px; padding-left: 40px; top: 200px;  position: fixed; 
margin-left: 510px;     left: 110px; }

 

That is OK in 1024*768 resolution but may need adjusting for larger window widths. I think you will have to think again about using position: fixed for the #col-right as the position: fixed right div overlaps at some window resolutions after my edit, but won't show in IE7 without my edit!

  • Author

Indeed. That didn't really work. The "left:0" makes #navbar flush to the extreme left margin rather than flush with #bgWrap that is 1004px wide and centred in the browser.

 

Same with "left:110" in #col-right - it becomes an absolute position and messed it up in Firefox-Mac too.

 

I just tried adding display:inline - a possible solution I found that didn't work. Interesting site though - going to keep reading.

 

Maybe I have to rebuild the whole banner again - try a different approach.

 

Actually !!! just thought of another solution. I've never tried to use a browser detect script before - I could do that and send IE users off to a different style sheet that doesn't have a floating banner, couldn't I? Would that be a bad thing to do?

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.