【问题标题】:Can I get hostname on CSS我可以在 CSS 上获取主机名吗
【发布时间】:2015-02-08 16:48:37
【问题描述】:
.trPic{ 
width:640px; 
height:480px; 
position:absolute; 
top:0px;
left:0px; 
width:640px; 
height:480px; 
background: url(http://192.168.2.150:8090/?action=stream) no-repeat; 
border:0px solid #000000; 
} 

我可以在 Css 上获取主机名吗?像 (http://hostname:8090/?action=stream) 因为我的服务器在不同的端口上运行,当我的 ip 更改或有人从局域网外连接时,我看不到流...

当我的 ip 更改示例:192.168.43.187 我必须将 css 文件更改为并且 localhost 使用 127.0.1.1 并且当我想流出 lan 时我必须将 css 更改为 http://publicip:8090/?action=stream

【问题讨论】:

  • 是的,应该可以,但是你没试过吗?
  • 使用 localhost 可能不是一个好主意。但是,您可以使用像 /?action=stream 这样的相对引用 - 请注意,静态媒体需要配置为在此 url 上正确服务
  • 去探索 /etc/hosts 或 Windows\System32\drivers\etc\hosts(Linux/Windows 依赖)并查看 localhost 是如何定义的,然后添加您自己的输入。
  • @GavinSimpson 我试过了,但是在局域网外并且我的本地 ip 更改时它无法正常工作......

标签: html css


【解决方案1】:

只需手动添加图像 你不需要托管你的图像兄弟XD

.trPic{ 
width:640px; 
height:480px; 
position:absolute; 
top:0px;
left:0px; 
width:640px; 
height:480px; 
background: url(/*ur_image*/) no-repeat; 
border:0px solid #000000; 
} 

【讨论】:

  • 谢谢,但我解决了它,但那不起作用,因为图像在另一个端口上:D 我只是基本使用 javascript :D
  • 你能给我的帖子投票吗? XD 不喜欢它
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-03-12
  • 2010-12-14
  • 2012-08-09
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多