html - IE 在 vi​​sual studio 和服务器上的调试之间显示不同的页面

标签 html css

这是 this 的延续问题。

我有一个 ASP.NET 应用程序,当在 IE8 中的 DEBUG 中查看时,某些部分的显示与显示已发布的 TEST 服务器位置不同。

当我在调试中查看页面时(通过 VS 2010),我看到了这个:

alt text

但是,当我发布到服务器上,直接查看时,是这样的:

alt text

标题框只有文本背景颜色为黑色,而不是整个部分。

这是 CSS:

.imageBox
{
    position: relative;
    float: left;
    border-style: solid;
    border-width: 1px;
    text-align: center;
}

.imageBoxTitle
{
    width: 100%;
    background-color: #333333;
    padding: 5px;
}

.imageBoxTitleLbl
{
    font-family: Verdana;
    font-weight: bold;
    font-size: small;
    color: White;
}

这是生成的 HTML

 <div class="imageBox">
    <div class="imageBoxTitle">
        <span id="MainContent_ImagesPanel_ImageHolder1_ImageBoxTitleLabel" class="imageBoxTitleLbl">ITEM OVERVIEW</span>
    </div>

    <div class="imagePlaceHolder">
        <p class=".centeredImage"><a id="MainContent_ImagesPanel_ImageHolder1_ImageHyperLink" href="UserImages/nu5t3hhs.jpg" target="_blank"><img src="UserImages/nu5t3hhs.jpg" height="200" width="200" /></a></p>
        <span id="MainContent_ImagesPanel_ImageHolder1_CustomValidator1" style="color:Red;visibility:hidden;">*</span>
    </div>

    <div class="imageAction">  
    </div>
</div>

所以我想这可能是某种缓存问题。但是,如果我对 CSS 稍作更改(例如更改背景颜色),它会拾取并显示它。此外,我已将动态生成的 GUID 添加到 css 文件的查询字符串中,因此它们永远不会被缓存。 Fiddler 确认它们也没有被缓存。

当通过 Visual Studio 调试查看页面与直接从服务器访问页面时,IE 似乎以不同方式呈现 HTML/CSS。

什么事情可能会导致这种行为?

更新:当我在已发布服务器上的 Chrome 或 Firefox 中查看页面时,它显示正确。我已经清除了 IE 缓存 (ctrl-f5),从服务器上删除了 .css 并重新加载,等等。

最佳答案

当 IE 在 localhost 上呈现时,它将使用标准兼容模式

但是,当它在 Intranet 上呈现时,它将使用兼容模式

不要问我它为什么这样做,这只是 MS 为给我们的开发者生活增添趣味而随意做的事情之一。

只需将此添加到您的 header 即可强制 IE 进入标准兼容模式:

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

享受 :)

关于html - IE 在 vi​​sual studio 和服务器上的调试之间显示不同的页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3770103/

相关文章:

html - CSS Main Body 不会拉伸(stretch)到页面?

c# - 从部分 View 中的表单发布 - 为什么会触发错误的 Controller 操作?

javascript - 幻灯片一次显示 2 张图片

javascript - 如何在新窗口中打开当前页面

jquery - 位置 : Fixed or Resizable but not both

javascript - 重新设置对 anchor 标记的关注

javascript - react : Calling Render() during animation. 会发生什么?

javascript - 为什么不需要 getElementById 来获取表单中的 ID

html - CSS 网格两列键 :Value Layout

jQuery Sortable 用于两列重新排序?