CSS 在本地主机上的表现不同
我正在开发一个网站,我想向某人展示它。所以我建立了一个网络服务器。现在,当我尝试通过 LAN 而不是使用本地主机访问网站时,我遇到了一些奇怪的行为。
首先,当我访问本地主机中的页面时,所有内容似乎都变得小得多。我设计了页面的宽度等,因为它看起来不错。现在,当我访问该网站时,它会填满整个页面。
其次,我使用 @font-face
作为标题等。这在我的本地主机上有效,但当我通过网络访问该页面时则无效。
最后,当我在手机上访问该页面时(使用 3g,所以不是我的家庭网络),CSS 根本没有渲染。
你能解释一下这种奇怪的行为吗?
I'm working on a website, and I wanted to show it to someone. So I set up a webserver. Now I'm getting some strange behavior when I'm trying to reach the website via LAN instead of using my localhost.
First of all, when I visit the page in my localhost, everything seems to be rendered much smaller. I designed the page at a width etc. because it looks good. Now when I visit the site it fills up the whole page.
Secondly, I'm using @font-face
for the titles etc. This works on my localhost, but not when I visit the page via my network.
And last, when I visit the page on my phone (using 3g, so not my home network), the css is not rendered at all.
Can you explain this strange behavior?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这一定是因为当您通过 LAN 查看时,某些样式表没有被传递。
当您查看 Firebug NET 选项卡(或类似选项卡)时,您可以验证是否包含并加载了所有样式表(没有 404)。
另外,如果您查看应该设置字体(例如)的元素,并检查其样式,正在应用什么?是样式不存在,还是样式存在但未按您的预期应用? (我想是前者)。
如果您在 DOM 检查器中查看字体不正确的文本,是否表明正在应用该样式?
This has got to be that some of the stylesheets are not getting delivered when you view over the LAN.
When you look in Firebug NET tab (or similar) can you verify that all the stylesheets are being included and loaded (no 404s).
Also, if you look at the element that should have a font-face (for example) set, and check its styles, what is being applied? Is it that the styles are not there, or are they there and not being applied as you expect? (I am thinking the former).
If you look at the text with incorrect font in DOM inspector, does it show that the style is being applied?