如何为网站提供动态 CSS 样式或自定义主题?
有很多方法可以为网站提供动态样式/主题,但我正在寻求一些对其他人来说效果良好的最佳实践或技术的帮助。
我正在创建一个网站,需要为客户提供创建或指定自己的颜色、样式、主题或布局的能力。 我还不确定我需要多少灵活性,但基本上我需要提供品牌功能。
我将使用 ASP.NET,并且愿意接受任何适合 ASP.NET 框架的想法。
There are plenty of ways to provide a dynamic style/theme for a web site, but I am looking for some help on some best practices or techniques that have worked well for others.
I am creating a web site that needs to provide the ability for customers to create or specify their own colors, style, theme, or layout. I'm not convinced how much flexibility I need yet, but basically I need to provide Branding capabilities.
I will be using ASP.NET, and am open to any ideas that will fit within the ASP.NET framework.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
使用 ASP.NET 2 及更高版本的主题将为您提供所需的一切。
Using Themes for ASP.NET 2 and greater will provide you everything you need for this.
我个人会选择基于 CSS 的解决方案。
您可以为 Web 应用程序中的每个页面定义元素的 ID 和 CSS 类,以便客户可以提供自己的 CSS 文件集。
这种方法与平台无关,因此创建自定义主题的开发人员不必被迫适应 ASP.NET 主题模型 - 她可能是一个没有编程知识的 Web 设计师。
I'd personally go for a CSS-based solution.
You could define the elements' IDs and CSS classes for each page in the web application, so that customers can provide their own set of CSS files.
This approach is platform-agnostic, so that the developer who creates the custom themes is not forced to fit into the ASP.NET themes model - she might as well be a web designer with no programming knowledge.
处理这个问题的最佳方法是制作一个漂亮的 CSS 文档,其中指定您想要提供自定义的所有区域,例如标题背景图像、背景和文本颜色等。然后构建应用程序代码以允许指定哪个主题加载并调出该 CSS 文件。
Best way to handle it would be to make a nice CSS document that will specify all the areas that you would like to offer customization, such as header background image, background and text colors, etc. Then build application code to allow specification of which theme to load, and bring up that CSS file.
主题可能是一个很好的解决方案,但重新阅读你的问题后我您认为您可能需要一种允许客户动态提交自己的品牌的方法,即无需修改任何文件,这是一种不干涉的方法? 拥有一个由 Web 表单组成的管理界面怎么样,客户可以自己上传图像和 CSS? 然后,您可以使用 HttpHandler 或类似的方法检索该内容。
Themes might be a good solution but having re-read your question I think you might be asking for a method for allowing customers to submit their own branding dynamically, i.e. without you having to modify any files, a hands-off approach? How about having an admin interface consisting of web forms where the customer can upload images and CSS themselves? You could then retrieve that content using a HttpHandler or similar.