创建 XP 风格左侧面板


通常情况下,在 Windows XP 的资源管理器文件夹中,左侧的面板(panel)包含一些常见任务。 本教程向您展示如何通过 easyui 的面板(panel)插件来创建 XP 左侧面板。

定义一些面板(panel)

我们定义一些面板(panel),这些面板(panel)用来显示一些任务。每个面板(panel)应该至少有折叠/展开工具按钮。

代码如下所示:

  1. <div style="width:200px;height:auto;background:#7190E0;padding:5px;">
  2. <div class="easyui-panel" title="Picture Tasks" collapsible="true" style="width:200px;height:auto;padding:10px;">
  3. View as a slide show<br/>
  4. Order prints online<br/>
  5. Print pictures
  6. </div>
  7. <br/>
  8. <div class="easyui-panel" title="File and Folder Tasks" collapsible="true" style="width:200px;height:auto;padding:10px;">
  9. Make a new folder<br/>
  10. Publish this folder to the Web<br/>
  11. Share this folder
  12. </div>
  13. <br/>
  14. <div class="easyui-panel" title="Other Places" collapsible="true" collapsed="true" style="width:200px;height:auto;padding:10px;">
  15. New York<br/>
  16. My Pictures<br/>
  17. My Computer<br/>
  18. My Network Places
  19. </div>
  20. <br/>
  21. <div class="easyui-panel" title="Details" collapsible="true" style="width:200px;height:auto;padding:10px;">
  22. My documents<br/>
  23. File folder<br/><br/>
  24. Date modified: Oct.3rd 2010
  25. </div>
  26. </div>

自定义面板(panel)的外观效果

请注意,这个视图外观效果不是我们想要的,我们必须改变面板(panel)的头部背景图片和折叠/展开按钮的图标。

做到这一点并不难,我们需要做的只是重新定义一些 CSS。

  1. .panel-body{
  2. background:#f0f0f0;
  3. }
  4. .panel-header{
  5. background:#fff url('images/panel_header_bg.gif') no-repeat top right;
  6. }
  7. .panel-tool-collapse{
  8. background:url('images/arrow_up.gif') no-repeat 0px -3px;
  9. }
  10. .panel-tool-expand{
  11. background:url('images/arrow_down.gif') no-repeat 0px -3px;
  12. }

由此可见,使用 easyui 定义用户界面非常简单。

下载 jQuery EasyUI 实例


下载地址