手持设备的样式表可以跳过加载图像吗

发布于 2024-08-27 01:06:07 字数 213 浏览 5 评论 0原文

我有一个用于台式机的样式表,另一个用于手持设备的样式表。该网页在桌面上显示时会显示一些图像,但在手持设备上显示时会隐藏这些图像。该页面显示为针对台式机和手持设备设计的。

当我检查服务器日志时,我发现手持设备实际上仍在加载图像,只是不显示它们。有没有办法阻止手持设备完全加载图像,因为它不需要它们,而不必维护两组网页?可以仅使用样式表来完成吗?

提前致谢。

雷·蒙德

I have a stylesheet for desktops, and another for handhelds. The web page displays some images when displayed on the desktop, but hides those images when displayed on handhelds. The page appears as designed for both desktops and handhelds.

When I check the server logs, I find that the handheld is actually still loading the images, just not displaying them. Is there a way to stop the handheld from loading the images entirely, since it doesn't need them, without having to maintain two sets of web pages? Can it be done using just stylesheets?

Thanks in advance.

Ray Mond

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

辞旧 2024-09-03 01:06:07

包括您不想在移动设备上显示的图像作为背景图像。然后,您可以在浏览器样式表中使用

.element { 
    background: #FFF url('image.png') no-repeat left top; /* or whatever */
}

,而在手持式样式表中,您只需不设置背景图像,因此,根据具体用法,您可以使用

.element {
    display: none;
}

.element { 
    background: #FFF;
}

但是,无法删除使用 < 包含的图像code> 之后通过 CSS 规则(只是 display: none 等,但这不会阻止它们加载,正如您所注意到的)。

Include the images you don't want to display on the mobile devices as background image. In the browser stylesheet you then can use

.element { 
    background: #FFF url('image.png') no-repeat left top; /* or whatever */
}

while in the handheld stylesheet you just don't set a background image, so, depending on the exact usage, you could use

.element {
    display: none;
}

or

.element { 
    background: #FFF;
}

However, it won't be possible to remove images you include with <img src="" /> afterwards through CSS rules (just display: none etc, but that wouldn't stop them from loading, as you noticed).

怀中猫帐中妖 2024-09-03 01:06:07

在标记之前发送每个 HTTP 标头的样式表:

Link: <compact.css>; rel="stylesheet"; media="handheld"

那么最常用的手持式浏览器 - Opera - 将不会加载图像。然而,WebKit (Safari) 仍然如此——甚至隐藏元素的背景图像!

Send your stylesheet per HTTP header before the markup:

Link: <compact.css>; rel="stylesheet"; media="handheld"

Then the most used handheld browser – Opera – won’t load the images. WebKit (Safari) still does, however – even background images for hidden elements!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文