本地网站使用(IP 地址或计算机名称)与 localhost 的渲染方式不同?
我有一个 MVC3 (razor) 站点发布到本地 IIS7 以进行测试。
当我通过“localhost”访问该站点时,它看起来与使用 IP 地址或计算机名访问时不同吗?
我已清除缓存并重新加载页面进行确认,但它们仍然显示不同。 CSS 必须加载才能提供正确的字体/颜色等,尽管“:hover”元素加载速度似乎慢得多?
我在网站上使用 JQuery/JQueryUI 是否有助于识别问题?
有什么想法吗?
编辑:更多信息
标题、标签和表定义是从 ViewBag.Title 构建的,或者循环遍历 ViewModel 中的行 - 没什么聪明的,只是标准的 MVC3/Razor 东西。
每个页面都使用相同的 css 文件,IE8 中的 F12 显示已加载正确的 css。
标题/副标题字体大小/颜色正确,只是位置不对? 表格边框显得更粗? 定位总体看起来有点“out”,但我不明白为什么会有这种差异?
防火墙/AV 包可以排除定位吗?
I have an MVC3 (razor) site published to IIS7 locally for testing purposes.
When I access the site via "localhost" it looks different from when I access using the IP address or machinename?
I have cleared my cache and re-loaded the pages to confirm and they still appear the different. The CSS must be loading to give the correct fonts/colours etc, although ":hover" elements appear to load much slower?
I am using JQuery/JQueryUI on the site if that helps identify the problem?
Any ideas?
Edit: More info
The titles, labels and table definition are build from ViewBag.Title, or looping through rows in a ViewModel - nothing clever, just standard MVC3/Razor stuff.
The same css file is used for every page, and F12 in IE8 shows the correct css has been loaded.
Title/subtitle font sizes/colours are correct, just their positioning is out?
Table border appears thicker?
Positioning generally seems a little "out", but I can't understand why there is this difference?
Can a firewall/AV package strip out positioning?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
开发人员工具应该显示 IE 在网站的两个实例之间没有使用相同的“浏览器模式”/“文档模式”,因为这就是问题所在。 IE 默认采用不同的模式,具体取决于您是否使用计算机名称(除其他外)。
将其添加到您的
应该可以解决问题:
Developer Tools should show that IE is not using the same "Browser Mode"/"Document Mode" between the two instances of the site, because that's the problem here. IE defaults to different modes depending on if you're using a machine name or not (amongst other things).
Adding this to your
<head>
should sort out the problem:我遇到了类似的问题,本地开发站点的大小与生产服务器上的大小不同。结果我在查看开发版本时忘记了缩放级别为 90%...这个答案帮助我意识到: https://superuser.com/questions/315448/ Different-font-size- Between-localhost-and-remote-server-in-firefox
I had a similar issue, where the sizes differed from the local development site to the one on the production server. Turned out that I forgot the zoom level to 90% when viewing the development version... This answer helped me realize that: https://superuser.com/questions/315448/different-font-size-between-localhost-and-remote-server-in-firefox
我在 IE11 中遇到了完全相同的问题,我使用了这段代码
,现在无论是本地主机还是我的计算机名称,页面总是呈现得很好。
I had exactly similar issue in IE11, I used this code
And now whether its localhost or my machine name, the page always rendered nicely.
只是想补充一点,如果您使用 HTML5 标签(nav、header 等),IE8 将在本地主机和远程主机上呈现不同的效果。
如果添加:
那么 IE8 将在本地和远程主机上显示相同的内容。
Just wanted to add, that if you use HTML5 tags (nav, header etc.) IE8 will render different on localhost and remote host.
If you add:
Then the IE8 will show the same on local and remote host.