如何在网络浏览器中切换主题

发布于 2024-09-13 15:59:04 字数 42 浏览 3 评论 0原文

我想更改 ASP.NET 网站的主题。但我必须给出切换主题的正常效果?

I want to change the theme in an asp.net website. but i have to give the normal effect of switching themes?

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

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

发布评论

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

评论(3

缪败 2024-09-20 15:59:04

你可以通过切换样式表来做到这一点 - 你可以使用 javascript 来做到这一点 - 有一个脚本使用 cookies 来做到这一点,所以主题是持久的 - 否则你可以使用会话在 asp 中做到这一点。

You can do this by switching style sheets - you can do this using javascript - there is a script around that uses cookies to do this so the theme is persistent - other wise you can probably do it in asp using sessions.

早乙女 2024-09-20 15:59:04

我最好的建议是将主题名称存储在用户的客户端变量中。

这是 Coldfusion 风格

<cfset client.myTheme = "forest">
<link rel="stylesheet" href="theme/<cfoutput>#client.myTheme#</cfoutput>.css" media="screen" type="text/css"/>

My best advice is to store the theme name in user's client variable.

Here is Coldfusion style

<cfset client.myTheme = "forest">
<link rel="stylesheet" href="theme/<cfoutput>#client.myTheme#</cfoutput>.css" media="screen" type="text/css"/>
美人骨 2024-09-20 15:59:04

另一种方法是在父 html 元素上切换类,例如 。这样做的优点是不需要下载额外的样式表。

这确实要求您从一开始就加载不同主题的所有不同样式,但在大多数情况下,不同主题的样式规则更改相对较少,并且大部分 CSS 负载被重置样式和其他样式占用。适用于所有主题的通用样式(当然也有例外,但在一般情况下它往往是正确的)。由于包含额外的 CSS 资源的加载时间成本非常高,并且有效负载增加(特别是在提供压缩资源时)很低,因此从一开始就包含额外的主题不会带来任何性能损失,事实上与将主题样式放在单独的文件中相比,可能会获得性能增益。此外,由于不需要加载额外的资源,因此主题切换速度会更快。

Another way to do it would be to switch the class on a parent html element, such as <body>. This has the advantage of not requiring an extra stylesheet to download.

This does require you to have all of your different styles for the different themes loaded from the start, but in most cases, there are relatively few style rule changes for different themes and the majority of the CSS payload is taken up by reset styles and other general styling that apply to all themes (there are of course exceptions to this, but in the general case it tends to be true). Since the load-time cost of including an additional CSS resource is very high, and the payload increase (especially if serving compressed resources) is low, you don't incur any performance penalty by including the extra themes from the beginning, and in fact are likely to have a performance gain versus putting the theme styles in a separate file. Additionally, themes will switch much faster because there are no extra resources to load.

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