CSS renders differently on web server than on development environment

Css

Css Problem Overview


I have this problem where the web application that I have created in my development environment, displays differently after I upload it to the web server.

I am using the same browser and the same machine to view the pages. The only thing different, is the "server". I am using .net 3.5 and on my development environment the pages are served using the ASP.net Development Server. On the web server, the pages are served using IIS 6.0.

I have only a single CSS file that is contained within the "App_Themes/Default" folder that is used to control all the CSS in my application.

Here are some of the things that don't display the same:

  1. I have a collapsible panel control that when expanded is supposed to show on top of all the other page elements. On the dev environment, it behaves correctly. On the web server, the panel slides underneath the other elements.

  2. I have my

    element defined with a background and a certain font size. When displayed on my development environment, the text displays on one line. However, on the web server, the text is wrapped even though the text is the same size. It's as if the containing div is somehow rendered "smaller".

  3. The width of buttons that do not have a fixed width (so the width is determined by the button text) is different between the development environment and the web server. The bottons on the server are always wider.

I checked to make sure there are no references to other CSS elements in the machine.config and global web.config on the server and on my development environment.

I know the server is reading from the CSS because in general, it looks similar (same colors, backgrounds, font style, etc). It's just that the sizes seems to be off and the layering of the divs.

Has anyone run in to this problem before? Any ideas of what I could look for?

Css Solutions


Solution 1 - Css

Looks like you are comparing them in Internet Explorer 8. Microsoft introduced different rendering modes for local and Internet servers so that web developers would break down in tears.

> If there’s no X-UA-Compatible value and site is in > Local Intranet security zone, it will be rendered > in EmulateIE7 mode by default.

Add X-UA-Compatible header or META to force full IE8 standards mode.

See also http://sharovatov.wordpress.com/2009/05/18/ie8-rendering-modes-theory-and-practice/

Solution 2 - Css

We were having an issue with compatibility modes too, so I ended up just adding:

<meta http-equiv="X-UA-Compatible" content="IE=Edge">

Since I knew it worked fine in IE7, 8, and 9.

Solution 3 - Css

I had the same problem in Google Chrome. Apparently media queries get messed up if the page is zoomed in or out. Make sure your zoom level is 100% for both sites.

Solution 4 - Css

This at least sounds like that the production server added a xml declaration to the HTML or changed the doctype which caused the page being rendered in non-standards-compliant mode. This is also known as quirks mode, you see this very good back in MSIE. The symptoms which you described are recognizeable as box model bug in MSIE.

Rightclick the pages and check the HTML source. Are they both exactly the same? (including meta tags, xml declaration, whitespace, etc)

If you're FTP'ing from Windows to Linux, please ensure that you're transferring in binary mode to ensure that the whitespace (spaces, linebreaks) remain unchanged. Also ensure that you're saving documents as UTF-8 (or at least ISO-8859-1) and NOT as MS-proprietary encoding such as CP1252.

Solution 5 - Css

For those of you that are having this problem in an Intranet site setting the meta tag won't fix the problem if "Display intranet sites in Compatibility View" is checked on (which it is in a lot of cases)

You have to send the HTTP response header at the server level, see here

Solution 6 - Css

The CSS that is coming from the server may be a older cached version - try refreshing the page using Ctrl+F5 so it get re-requested.

Solution 7 - Css

For me, Internet Explorer's Compatibility View Settings was the issue:

accessing Compatibility View Settings

Compatibility View Settings

After the check-boxes were un-set, the CSS renders perfectly

Solution 8 - Css

We had the same issue, fixed on IE9 & IE11 with this:

<head>
    <meta http-equiv="X-UA-Compatible" content="IE=Edge"/>
</head>

Solution 9 - Css

Juste add this to your web.config file :

<system.webServer>
    <httpProtocol>
        <customHeaders>
            <clear />
            <add name="X-UA-Compatible" value="IE=8" />
        </customHeaders>
  </httpProtocol>
</system.webServer>

Solution 10 - Css

I had the same issue. Our network uses Win7 with IE11 throughout. For me the solution was to, on my local machine adding "localhost" to the list in IE's compatibility settings > "Websites you've added to compatibility View". IE > Tools > Compatibilty View settings.

BTW our NA has every machine setting IE11 to "Display intranet sites in Compatibility View" automatically checked by a group policy.

Solution 11 - Css

This often happens to me when the 'server' version is cached somehow. Refreshing did the trick. Throwing away 'temporary internet files' does it, too.

Solution 12 - Css

I just had this problem. I'd changed my style sheet and HTML code. It looked great on locally but didn't work on the server. I found that in Visual Studio the CSS file's "Copy to Output Directory" was set to "Do not copy". So my CSS updates were not getting deployed. Sometimes the problem is just user error.

Solution 13 - Css

Can be caused by minification, e.g. on dev machine you have

<span>AAA</span>
<span>BBB</span>

but on remote server it becomes

<span>AAA</span><span>BBB</span>

and a space between them gets lost.

Solution 14 - Css

try this,.

<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE8" />

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionAmanda MyerView Question on Stackoverflow
Solution 1 - CssQuentinView Answer on Stackoverflow
Solution 2 - CssPablo ClausView Answer on Stackoverflow
Solution 3 - CssrostamView Answer on Stackoverflow
Solution 4 - CssBalusCView Answer on Stackoverflow
Solution 5 - CssMigsView Answer on Stackoverflow
Solution 6 - CssOdedView Answer on Stackoverflow
Solution 7 - CssxameeramirView Answer on Stackoverflow
Solution 8 - CssMJPView Answer on Stackoverflow
Solution 9 - CssPortekoiView Answer on Stackoverflow
Solution 10 - CssDoreenView Answer on Stackoverflow
Solution 11 - CssxtoflView Answer on Stackoverflow
Solution 12 - CssGary in OhioView Answer on Stackoverflow
Solution 13 - CssDenis ZhbankovView Answer on Stackoverflow
Solution 14 - CssDevendra PatelView Answer on Stackoverflow