[原]利用CSS3实现模拟一个windows7桌面的页面

利用CSS3的border-radius和box-shadow可以很容易的实现一个类似Windows7的桌面效果的页面,效果如图

主要是圆角的设计,透明设计,参考css3实战地5章的类容,马马虎虎做了一下午,只有样式,没有事件,一个html文件,一个css文件。源码以下:

simuWin7.html:

 1 <html>
 2 <head>
 3     <title>用CSS3模拟Windows7的界面</title>
 4     <link rel="stylesheet" href="./simuWin7.css" />
 5 </head>
 6 <body>
 7 <!-- 桌面 -->
 8 <div id="desktop">
 9     <!-- 第一个窗口 -->
10     <div id="bgwindow" class="window first">
11         <span>窗口1</span>
12         <div class="control">
13             <button class="ctrl">-</button>
14             <button class="ctrl">O</button>
15             <button class="ctrl">X</button>
16         </div>
17         <div class="content">这是第一个窗口</div>
18     </div>
19 
20     <!-- 窗口 -->
21 
22     <div id="frontWindow" class="window">
23         <span>窗口2</span>
24 
25         <div class="control">
26             <button class="ctrl">-</button>
27             <button class="ctrl">O</button>
28             <button class="ctrl">X</button>
29         </div>
30         
31         <div id="winInput">
32             <input type="text" placeholder="hello world">
33             <input type="text"  placeholder="again">
34         </div>
35         <div id="winContent" class="content">这是第二个窗口的文本区域</div>
36     </div>
37 
38     <!-- 开始菜单&工具栏 -->
39     <div id="startmenu">
40         <button id="winflag">Start</button>
41         <span id="tollBtn">
42             <button class="application">A</button>            
43             <button class="application">B</button>
44             <button class="application">C</button>            
45             <button class="application">D</button>
46             <button class="application">E</button>
47             <button class="application">F</button>
48             <button class="application">G</button>
49             <button class="application">H</button>
50         </span>
51     </div>
52 
53 </div>
54 
55 </body>
56 </html>

simuWin7.css:

  1 body {
  2     padding: 0;
  3     margin: 0;
  4     height: 100%;
  5 }
  6 
  7 /*background of desktop*/
  8 #desktop {
  9     background: #2c609b;
 10     height: 100%;
 11     width: 100%;
 12     font: 12px "Segoe UI", Tahoma, sans-serif;
 13     position: relative;
 14     -moz-box-shadow: inset 0 -200px 100px #032b5c,
 15                      inset -100px 100px 100px #2073b5,
 16                      inset -100px 200px 100px #1f9bb1;
 17     -webkit-box-shadow: inset 0 -200px 100px #032b5c,
 18                         inset -100px 100px 100px #2073b5,
 19                         inset -100px 200px 100px #1f9bb1;
 20     box-shadow: inset 0 -200px 100px #032b5c,
 21                 inset -100px 100px 100px #2073b5,
 22                 inset -100px 200px 100px #1f9bb1;
 23     overflow: hidden;
 24 }
 25 
 26 /*startmenu*/
 27 #startmenu {
 28     /*position*/
 29     position: absolute;
 30     bottom: 0;
 31     /*size*/
 32     height: 40px;
 33     width: 100%;
 34     background: rgba(178, 215, 255, 0.25);
 35     -webkit-box-shadow: 0 -2px 20px rgba(0,0,0,0,25);
 36     -moz-box-shadow: 0 -2px 20px rgba(0,0,0,0.25),
 37         inset 0, 1px #042754,
 38         inset 0 2px #5785b0;
 39     box-shadow: 0 -2px 20px rgba(0,0,0,0.25),
 40         inset 0, 1px #042754,
 41         inset 0 2px #5785b0;
 42     overflow: hidden;
 43 }
 44 
 45 #startmenu button {
 46     font-size: 1.6em;
 47     color: rgba(0,0,0,0.1);
 48     margin-top: 6px;
 49     text-shadow: 0px 0px 1px #00294b;
 50     text-
 51 }
 52 
 53 /*startmenu*/
 54 #startmenu #winflag {
 55     float: left;
 56     width: 60px;
 57     height: 34px;
 58     margin: 3px 8px;
 59     /*padding: 0 auto 0;*/
 60     background: #034a76;
 61     border: none;
 62     -moz-border-radius: 18px;
 63     -webkit-border-radius: 18px;
 64     border-radius: 18px;
 65 
 66     -moz-box-shadow: 0 0 1px #34f,
 67                 0 0 3px #000,
 68                 0 0 3px #000;
 69     -webkit-box-shadow: 0 0 1px #34f,
 70                 0 0 3px #000,
 71                 0 0 3px #000;
 72     box-shadow: 0 0 1px #34f,
 73                 0 0 3px #000,
 74                 0 0 3px #000;
 75 }
 76 
 77 /*taskbar sheet*/
 78 #startmenu .application {
 79     position: relative;
 80     height: 34px;
 81     width: 60px;
 82     bottom: 3px;
 83     background:rgba(14, 59, 103, 0.25);
 84     border: 1px solid rgba(0,0,0,0.6);
 85     -webkit-border-radius: 4;
 86     -moz-border-radius: 4;
 87     border-radius: 4;
 88 }
 89 
 90 #startmenu .application:hover {
 91     background-color: hsla(240,70%, 70%, 0.6);
 92 }
 93 
 94 #startmenu #winflag:hover {
 95     background-color: hsla(150, 50%, 70%, 0.5);
 96 }
 97 
 98 /*window basic style*/
 99 .window {
100     position: absolute;
101     left:150px;
102     top:100px;
103     width: 300px;
104     height: 400px;
105     padding: 8px;
106 
107     /*特殊效果*/
108     border: 1px solid hsla(0,100%,0%,0.6);
109     background: rgba(178, 215, 255, 0.75);
110 
111     -webkit-border-radius: 8px;
112     -moz-border-radius: 8px;
113     border-radius: 8px;
114 
115     /*shadow*/
116     -webkit-box-shadow: 0 2px 32px #000,
117     0 0 1px #000,
118     0 0 1px #000;
119     -moz-box-shadow: 0 2px 16px #000,
120     0 0 1px #000,
121     0 0 1px #000;
122 
123     box-shadow: 0 2px 16px #000,
124     0 0 1px #000,
125     0 0 1px #000;
126 
127     text-shadow: 0 0 10px #fff;
128 }
129 
130 .window span {display: block;}
131 
132 .window input {
133     width: 100px;
134     margin-right: 40px;
135     -webkit-border-radius: 4px;
136     -moz-border-radius: 4px;
137 
138     -moz-box-shadow: 0 0 2px #fff,
139     0 0 1px #fff,
140     inset 0 0 3px #fff;
141     -webkit-box-shadow: 0 0 2px #fff,
142     0 0 1px #fff;
143     /*inset 0 0 3px #fff;*/
144     box-shadow: 0 0 2px #fff,
145     0 0 1px #fff,
146     inset 0 0 3px #fff;
147 }
148 
149 .window winInput {margin-left: 12px;}
150 
151 .window.first {
152     left:300px;
153     top: 180px;
154     opacity: 0.66;
155 }
156 .window span {margin-bottom:20px;}
157 .window.first span {margin-bottom: 60px;}
158 
159 .window .content {
160     margin-top: 16px;
161     padding: 10px;
162     height:250px;
163     background: hsla(0, 0%, 100%, 0.6);
164     border: 1px, dotted, #000;
165 
166     -webkit-border-radius: 6px;
167     -moz-border-radius: 6px;
168     border-radius: 6px;
169 
170 
171     -webkit-box-shadow: 0 0 5px #fff,
172     0 0 1px #fff;
173     /*inset 0 1px 2px #aaa;*/
174     -moz-box-shadow: 0 0 5px #fff,
175     0 0 1px #fff,
176     inset 0 1px 2px #aaa;
177     box-shadow: 0 0 50px hsla(120, 90%, 60%, 0.7),
178     0 0 1px #fff,
179     inset 0 1px 2px #aaa;
180 
181     text-shadow: none;
182 }
183 
184 .window .control {
185     position: relative;
186     left: 220px;
187     top: -40px;
188 }
189 
190 .window.first .control {top: -80px;}
191 
192 .window .control .ctrl {
193     position: relative;
194     /*height: 34px;*/
195     width: 26px;
196     /*bottom: 3px;*/
197     background:rgba(14, 59, 103, 0.25);
198     border: 1px solid rgba(0,0,0,0.6);
199     -webkit-border-radius: 3;
200     -moz-border-radius: 3;
201     border-radius: 3;
202 }
203 
204 .window .control .ctrl:hover {
205     background-color: hsla(240,70%, 80%, 0.6);
206 }

 

对于shadow的使用还有些难以把握,对于色彩的把握基本没什么方法,纯粹乱配,不过熟悉了一下hsl,hsla,rgba的基本用法,收获还是有的,以后要加强配色的感性认识。

转载于:https://www.cnblogs.com/kiwi/archive/2013/03/01/2939531.html

  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
关于小七 项目名称:小七 / Seven 当前版本:2.0 项目作者:夜末 关于兼容: 小七兼容除IE6以外的所有浏览器 开源许可证:Apache 小七(Seven)使用Apache开源许可证。 您可以随意修改和使用小七(Seven)的源码,但在您修改或使用的过程中,请遵循Apache开源协议。这意味着当您修改或再次分发小七(Seven)的源码时,必须保留作者版权信息。 什么是小七 ? 小七是一款基于JQuery的窗口界面模拟插件,它可以帮助WEB开发者提高开发效率及用户体验,并利用窗口的优势提供多任务同时操作的用户界面。 小七的愿景 小七是免费开源的项目,之所以选择开源是因为我希望可以和广大开发者一起分享、完善小七,让小七从基础窗口框架变成WEB OS。 我为什么开发小七? 这还得追溯到两年前开发的一个项目,那个项目的具体名称和用途我已经记不清了,我只记得当时在做后台界面时突然觉得很繁琐,每次写后台都得先做界面,而且一般的框架(frame)界面也只能运行单个任务,用户体验也不是很好。于是我决定开发小七,一个基于WEB的窗口框架,使WEB开发者可以专注于内容,这样不仅可以提高开发效率和用户体验还可以利用窗口的优势提供多任务同时操作的用户界面。 小七的用途 小七可以用于大部分的WEB界面开发,比如后台管理主页开发、表格展示、聊天窗口构建等等...

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值