Posted By: System | Sep 5th, 2007 @ 6:57 AM
page 1 of 1
Comments: 10 | Views: 2561

Hi. I am having trouble understanding css compatibility with IE and other browsers. I am a complete novice when it comes to css and any web technology in general so bear with me.

I have implemented a simple website in asp.net which uses div tags and css to manage the layout. However, depending on the browser I get different results!

I cant seem to work out why? Why does the same site in Firefox and IE look so different?

http://www.anon.co.uk


jsampsonPC
jsampsonPC
SampsonBlog.com SampsonVideos.com
Just by peeking into your markup with IE Dev Toolbar, first suggestion I could give is to give yourself a wrapper-div to hold all of your elements.

<div id="myContainer">
   
    <div class="header">...</div>
    <div class="menu">...</div>
    ...

</div>

You can then apply rules to the outer-most container, "myContainer".

#myContainer {
    width:800px;
    margin:auto;
}

For example. This would keep your site a fixed width, and center it up in the browser. The reason I mention the width is because in FF it looked similar to IE, until I expanded the width of my FF browser...then everything fell apart.

Another thing I would suggest is getting rid of your "leftSpacer" and "rightSpacer" divs. Instead of using that method, use left-margin and right-margin on your leftCont and rightCont.

Might consider this markup, or something similar:

<div id="container">
   <div id="header">
      <div id="mainNav">...</div>
   </div>
   <div id="content">
      <div id="leftCont">...</div>
      <div id="centCont">...</div>
      <div id="rightCont">...</div>
   </div>
   <div id="footer">...</div>
</div>

Just a couple suggestions. I'll take another look and see if anything else immediately strikes me.

Of relevancy, check out www.SampsonVideos.com if you're just getting started with CSS etc Wink
Ok, thats alot. Made a lot of sense. I'll make them changes now. And I will have to view your videos!
jsampsonPC
jsampsonPC
SampsonBlog.com SampsonVideos.com
anon wrote:
Ok, thats alot. Made a lot of sense. I'll make them changes now. And I will have to view your videos!


Sounds good man. Be sure to let us know how the changes turn out. We're all here to help Tongue Out
Ok thanks to your help John, my divs are now organised more efficiently and I think I am finally getting the hang of this.

I have one more problem though.

HERE

I have a number of images on a page that I am trying to arrange.

For the top right images on the page, I positioned absolutely.

For the mouse mat/place mat images, they are position relatively. I used another wrapper div for each which each individual image in its own div.

The problems I have are:

In IE the top images are out of alignment and the mouse/place mat images are fine.

In FF the top images are fine but the place mat images are out of alignment. The mouse images are fine.

Also, where the images are place down the page and moved relatively - I now have a huge amount of white space below. How can get rid of this?

Also, when viewed in IE - I keep getting a notification saying the page wants to install flash! I havent even used flash on any page - why could this be coming up? This could just be my computer playing tricks on me though!

Again - much thanks for any help.

After some playing around I have concluded that:

1. the flash problem was just my computer

2. What is causing the layouts to be altered between browsers may have something to do with the margins. I noticed that in IE, the header does not start at the top of the page - in fact it is a quite a few pixels down. Also - IE adds larger spacing between the images I have that run along the edges of the master page. This results in the absolute positions being out.

I have tried setting every margin to 0 but still no luck. Any one have any ideas?
I recommend creating a "reset" style that sets every tag to zero margins and zero padding.  This way, you can selectivly add margins and padding as needed, rather than battling with the different margins that each browser sets by default.

Try the following style.  Put it at the top of your stylesheet.  If any other tags start misbehaving and adding margins, just add it to the list.

html,body,h1,h2,h3,h4,h5,h6,p,a,ul,ol,li,table,tr,td,img,form,input,textarea,pre,blockquote
{
margin: 0px;
padding: 0px;
}

Sorry, double post.  Got an ASP.NET error from the forums.
jsampsonPC
jsampsonPC
SampsonBlog.com SampsonVideos.com
Soviut wrote:
I recommend creating a "reset" style that sets every tag to zero margins and zero padding.  This way, you can selectivly add margins and padding as needed, rather than battling with the different margins that each browser sets by default.

Try the following style.  Put it at the top of your stylesheet.  If any other tags start misbehaving and adding margins, just add it to the list.

html,body,h1,h2,h3,h4,h5,h6,p,a,ul,ol,li,table,tr,td,img,form,input,textarea,pre,blockquote
{
margin: 0px;
padding: 0px;
}


Might be easier to use say

* {
   margin:0;
   padding:0;
}

And then explicitly declare margins and paddings on things later on if needed? Smiley
W3bbo
W3bbo
The Master of Baiters
jsampsonPC wrote:

Soviut wrote:I recommend creating a "reset" style that sets every tag to zero margins and zero padding.  This way, you can selectivly add margins and padding as needed, rather than battling with the different margins that each browser sets by default.

Try the following style.  Put it at the top of your stylesheet.  If any other tags start misbehaving and adding margins, just add it to the list.

html,body,h1,h2,h3,h4,h5,h6,p,a,ul,ol,li,table,tr,td,img,form,input,textarea,pre,blockquote
{
margin: 0px;
padding: 0px;
}


Might be easier to use say

* {
   margin:0;
   padding:0;
}

And then explicitly declare margins and paddings on things later on if needed? Smiley


This is a hack-on-a-hack.

anon: I'm not going to lie. The markup of your webpage is attrocious. You've got inline styles mixed with tables with absolutely and flow-positioned boxes. It's no-wonder it's hard to get to work properly. Start over from a design in photoshop or something. Not even I would attempt to "fix" the XHTML/CSS. The overall design is quite trivial anyway.

I'm kinda busy ATM, but I'll post the XHTML and CSS of my interpretation of your design in a few minutes, see if you can spot the difference Wink (or rather, the similarities after I'm through with it).
W3bbo
W3bbo
The Master of Baiters
I've done a fairly faithful conversion and made a 40 minute screencast of it.

....but the screencast is 813MB big and the sound gets out of sync.

I'm going to see what I can do about getting the sound back in sync and compressing it suitably.
page 1 of 1
Comments: 10 | Views: 2561
Microsoft Communities