HTML实现仿Windows桌面主题特效的实现


Posted in HTML / CSS onJune 28, 2022
在线演示地址:https://haiyong.site/win/

✨ 项目基本结构

目录结构如下:

├── jsLib
│   ├── jquery.winResize.js
│   ├── jquery-1.6.2.js
│   ├── jquery-1.6.2.min.js
│   ├── jquery-ui-1.8.16.custom.min.js
│   ├── myLib.js
│   ├── external
│   ├── jquery-smartMenu
│   ├── themes
│   └── ui
├── icon
├── images
├── wallpapers
└── index.html

HTML实现仿Windows桌面主题特效的实现

HTML 代码

HTML 主要代码:

<a href="https://haiyong.site" class="powered_by">Powered by haiyong.site 注意:双击桌面应用即可点开</a>
<ul id="deskIcon">
  <li class="desktop_icon" id="win11" path="https://haiyong.site/"> <span class="icon"><img src="icon/icon14.png"/></span>
    <div class="text">海拥
      <div class="right_cron"></div>
    </div>
  </li>
 <li class="desktop_icon" id="win11" path="https://haiyong.blog.csdn.net/"> <span class="icon"><img src="icon/csdn.png"/></span>
   <div class="text">CSDN
     <div class="right_cron"></div>
   </div>
 </li> 
  <li class="desktop_icon" id="win11" path="https://juejin.cn/user/2040341402229751"> <span class="icon"><img src="icon/juejin.png"/></span>
    <div class="text">掘金
      <div class="right_cron"></div>
    </div>
  </li>  
  <li class="desktop_icon" id="win11" path="https://space.bilibili.com/63551025"> <span class="icon"><img src="icon/bilibili.png"/></span>
    <div class="text">bilibili
      <div class="right_cron"></div>
    </div>
  </li>  
</ul>
<div id="taskBar">
  <div id="leftBtn"><a href="#" class="upBtn"></a></div>
  <div id="rightBtn"><a href="#" class="downBtn"></a> </div>
  <div id="task_lb_wrap">
    <div id="task_lb"></div>
  </div>
</div>
<div id="lr_bar">
  <ul id="default_app">
    <li id="app0"><img src="icon/icon1.png" title="海拥" path="https://haiyong.site/"/></li>
    <li  id="app2"><img src="icon/icon0.png" title="工具" path="https://haiyong.site/tools"/></li>
    <li id="app3"><img src="icon/icon2.png" title="交流群" path="https://app.yinxiang.com/fx/8aa8eb1b-7d45-4793-a160-b990d9da2e75"/></li>
    <li id="app4"> <img src="icon/icon3.png" title="联系作者" path="https://haiyong.site/img/qrcode/weixin.png"/></li>
    <li id="app1"><img src="icon/icon11.png" title="Jquery学堂" path="http://www.jq22.com/?Jquery.aspx"/></li>
  </ul>
  <div id="default_tools"> <span id="showZm_btn" title="显示桌面"></span><span id="shizhong_btn" title="时钟"></span><span id="weather_btn" title="天气"></span> <span id="them_btn" title="主题"></span></div>
  <div id="start_block"> <a title="开始" id="start_btn"></a>
    <div id="start_item">
      <ul class="item admin">
        <li><span class="adminImg"></span> Admin</li>
      </ul>
      <ul class="item">
        <li><span class="sitting_btn"></span>系统设置</li>
        <li><span class="help_btn"></span>使用指南 <b></b></li>
        <li><span class="about_btn"></span>关于我们</li>
        <li><span class="logout_btn"></span>退出系统</li>
      </ul>
    </div>
  </div>
</div>
</div>

? CSS 代码

CSS主要代码:

body, div, dl, dt, dd, ul, ol, li, h1, h2, h3, h4, h5, h6, pre, form, fieldset, input, textarea, p, blockquote, th, td {
	margin:0;
	padding:0;
}
table {
	border-collapse:collapse;
	border-spacing:0;
}
fieldset, img {
	border:0;
}
address, caption, cite, code, dfn, em, strong, th, var {
	font-style:normal;
	font-weight:normal;
}
ol, ul, li {
	list-style:none;
}
caption, th {
	text-align:left;
}
h1, h2, h3, h4, h5, h6 {
	font-size:100%;
	font-weight:normal;
}
q:before, q:after {
	content:”;
}
abbr, acronym {
	border:0;
}
* {
	margin:0;
	padding:0
}

页面基础样式

/*页面基础样式*/
html {
	overflow:hidden;
}
body {
	font-size: 12px;
	background:#06C url(wallpapers/menglong2.jpg) repeat scroll center center;
	font-family: Tahoma, Geneva, sans-serif;
	margin:0;
	padding:0
}
a {
	font-size: 12px;
}
a:link {
	text-decoration: none;
	color: #FFF;
}
a:visited {
	text-decoration: none;
	color: #FFF;
}
a:hover {
	text-decoration: none;
	color: #FFF;
}
a:active {
	text-decoration: none;
	color: #FFF;
}
.corner {/*只在支持css3的高级浏览器起作用*/
	-moz-border-radius: 5px;
	-webkit-border-radius: 5px;
	border-radius: 5px;
	-moz-box-shadow: 2px 2px 8px #444;
	-webkit-box-shadow: 2px 2px 8px #444;
	box-shadow:2px 2px 8px #444;
}
.loading {
	background:url(images/loading.gif) no-repeat center center
}

界面布局样式

/*界面布局样式*/
.powered_by {
	width:160px;
	height:25px;
	line-height:25px;
	background:url(images/powered-by.png) no-repeat left center;
	color:#CCC;
	text-indent:26px;
	display:block;
	outline:none;
	position:absolute;
	right:20px;
	bottom:60px;
}

任务栏样式

#taskBar {
	width:100%;
	height:40px;
	line-height:40px;
	position:absolute;
	right:0;
	bottom:0;
}
#leftBtn {
	width:100px;
	height:40px;
	float:left;
	display:none;
}
#rightBtn {
	width:100px;
	height:40px;
	float:right;
	display:none;
}
#leftBtn a, #rightBtn a {
	display:block;
	width:100px;
	height:40px;
	outline:none;
	background-image:url(images/lr_btn.png);
	background-repeat:no-repeat;
}
#leftBtn a {
	background-position:left top;
}
#rightBtn a {
	background-position:right top;
}
#leftBtn a:hover {
	background-position:left bottom
}
#rightBtn a:hover {
	background-position:right bottom
}
#task_lb_wrap {
	height:40px;
	line-height:40px;
	overflow:hidden;
	position:relative;
}
#task_lb {
	width:auto;
	height:auto;
	position:absolute;
	top:0;
	right:0;
}
#task_lb a {
	display:inline-block;
	outline:none;
	width:100px;
	height:40px;
	background-image:url(images/taskHdBtn.png);
	background-repeat:no-repeat;
	text-align:center;
	line-height:40px;
	float:right
}
#task_lb .defaultTab {
	background-position:right top;
	color:#ccc
}
#task_lb .defaultTab:hover {
	background-position:right bottom;
}
#task_lb .selectTab {
	background-position:left top;
	color:#FFF
}
#task_lb .selectTab:hover {
	background-position:left bottom
}
#shizhong_btn {
	background:url(images/timer.png) no-repeat center center
}
#weather_btn {
	background:url(images/wheather.png) no-repeat center center
}
#sound_btn {
	background:url(images/sound_open.png) no-repeat center center
}
#showZm_btn {
	background:url(images/show-desktop.png) no-repeat center center
}
#them_btn {
	background:url(images/skin.png) no-repeat center center
}

侧边浮动栏

#lr_bar {
	width:73px;
	height:auto;
	position:absolute;
	left:0;
	top:30px;
	background:url(images/dock_top.png) repeat-y left top;
	z-index:90;
	-moz-box-shadow: 0px 3px 15px #444;
	-webkit-box-shadow: 0px 3px 15px #444;
	box-shadow:0px 3px 15px #444;
	padding-top:5px;
}

开始按钮样式

#start_block {
	width:73px;
	height:56px;
	position:absolute;
	left:0;
	bottom:-56px;
	background:url(images/dock_b.png) no-repeat left bottom;
	-moz-box-shadow: 0px 5px 15px #444;
	-webkit-box-shadow: 0px 5px 15px #444;
	box-shadow:0px 5px 15px #444;
}
#start_btn {
	display:block;
	width:48px;
	height:48px;
	background:url(images/start-btn.png) no-repeat center bottom;
	margin:4px auto 0 auto;
	outline:none;
	z-index:501;
	cursor:pointer;
}
#start_btn:hover {
	background-position:center top
}

开始菜单样式

#start_item {
	width:180px;
	height:auto;
	padding:5px 0;
	background: url(images/start_item_bg.png) repeat;
	position:absolute;
	z-index:500;
	left:75px;
	bottom:0px;
	display:none;
	-moz-border-radius: 5px;
	-webkit-border-radius: 5px;
	border-radius: 5px;
	-moz-box-shadow: 2px 2px 5px #444;
	-webkit-box-shadow: 2px 2px 5px #444;
	box-shadow:2px 2px 5px #444;
}
#start_item .item {
	width:100%;
	height:auto;
	border-top:1px solid #999
}
#start_item .item li {
	width:98%;
	height:24px;
	overflow:hidden;
	zoom:-1;
	padding:6px 0;
	line-height:24px;
	margin:0 auto;
	color:#FFF;
}
#start_item .item li:hover {
	background:url(images/start_item_over.png) repeat-x left bottom;
	cursor:pointer
}
#start_item .item li span {
	display:inline-block;
	width:24px;
	height:24px;
	background-image:url(images/start_itembtn.png);
	background-repeat:no-repeat;
	margin:0 10px;
	float:left;
}
#start_item .item li b {
	width:10px;
	height:24px;
	background:url(images/item-child.png) no-repeat center center;
	display:inline-block;
	float:right;
	margin-right:10px;
}
#start_item .sitting_btn {
	background-position:left -140px;
}
#start_item .help_btn {
	background-position:left -44px;
}
#start_item .about_btn {
	background-position:left -164px;
}
#start_item .logout_btn {
	background-position:left -20px;
}
#start_item .admin {
	border-bottom:1px solid #444;
	padding:5px 0;
	border-top:none;
}
#start_item .item li .adminImg {
	border:1px solid #E0E0E0;
	background-position:left -92px;
	background-color:#FFF;
}

默认小工具

#default_tools {
	width:71px;
	height:auto;
	overflow:hidden;
	zoom:-1;
	padding:5px 0;
	border-top:1px solid #555;
	margin:0 auto;
}
#default_tools span {
	width:30px;
	height:30px;
	display:inline-block;
	margin:0 0 0 3px;
	cursor:pointer;
	float:left;
}

默认应用程序

#default_app {
	width:73px;
	height:auto;
	padding:5px 0;
	position:relative;
}
#default_app li {
	width:48px;
	height:48px;
	overflow:hidden;
	margin:3px auto;
	padding:6px;
}
#default_app li img {
	width:48px;
	height:48px;
	cursor:pointer;
}
#default_app .btnOver {
	background:url(images/default_appbtn_bg.png) no-repeat center center
}

重写右键菜单样式

.smart_menu_box .smart_menu_a {
	color:#333
}
.smart_menu_box .smart_menu_li_separate {
	border-bottom:1px solid #d6d5d5;
}

窗口样式

.windows {
	min-width:240px;
	min-height:200px;
	width:700px;
	height:560px;
	position:absolute;
	display:none;
	background-color:#E0E0E0;
}
.win_title {
	width:100%;
	height:26px;
	line-height:26px;
	background:#E0E0E0 url(images/titlebar_bg_cur.png) repeat-x left center;
	-moz-border-radius: 5px;
	-webkit-border-radius: 5px;
	border-radius: 5px;
}
.win_title b {
	color:#333;
	margin-left:10px;
}
.win_title .win_btnblock {
	width:auto;
	padding:0 5px;
	float:right;
	height:17px;
	margin:4px 3px 0 0;
}
.win_title .win_btnblock a {
	display:inline-block;
	width:26px;
	height:17px;
	background-image:url(images/windowBtn.png);
	background-repeat:no-repeat;
	float:left;
	margin:0 1px;
	outline:none;
}
.winMaximize {
	background-position:right bottom;
}
.winMaximize:hover {
	background-position:right top;
}
.winHyimize {
	background-position:-26px bottom;
}
.winHyimize:hover {
	background-position:-26px top;
}
.winClose {
	background-position:-52px top;
}
.winClose:hover {
	background-position:-52px bottom;
}
.winMinimize {
	background-position:left bottom;
}
.winMinimize:hover {
	background-position:left top;
}
.winframe {
	width:100%;
	height:auto;
	margin:0 0 0 3px;
	padding:0
}

桌面图标

#deskIcon {
	width:100%;
	height:auto;
	overflow:hidden;
	zoom:-1;
	position:relative;
}
.desktop_icon {
	width:86px;
	height:88px;
	cursor:pointer;
	margin-left:-1000px;
	text-align:center;
}
.desktop_icon span {
	display:block;
}
.desktop_icon .icon {
	width:50px;
	height:50px;
	margin:5px auto;
}
.desktop_icon .icon img {
	width:50px;
	height:50px;
}
.desktop_icon .text {
	display:inline-block;
	width:auto;
	height:22px;
	line-height:22px;
	text-align:center;
	color:#fff;
	background:url(images/iconTextbg.png) no-repeat left center;
	position:relative;
	padding-left:10px;
	margin-right:10px;
}
.desktop_icon .right_cron {
	width:10px;
	height:22px;
	position:absolute;
	right:-10px;
	top:0;
	background:url(images/iconTextbg_right.png) left center no-repeat;
}
.desktop_icon_over {
	background:url(images/icon_over.png) no-repeat center center;
}

? JS 代码

JS代码较多这里只展示部分JS代码,完整源码可在文末获取

//声明desktop空间,封装相关操作
myLib.NS("desktop");
myLib.desktop={
	winWH:function(){
		$('body').data('winWh',{'w':$(window).width(),'h':$(window).height()});
 	},
	desktopPanel:function(){
		$('body').data('panel',{
					   'taskBar':{
					   '_this':$('#taskBar'),
					   'task_lb':$('#task_lb')
										},
					   'lrBar':{
					   '_this':$('#lr_bar'),	   
					   'default_app':$('#default_app'),
				       'start_block':$('#start_block'),
				       'start_btn':$('#start_btn'),
					   'start_item':$('#start_item'),
					   'default_tools':$('#default_tools')
							},				
						'deskIcon':{
							'_this':$('#deskIcon'),
							'icon':$('li.desktop_icon')
							},
						'powered_by':$('a.powered_by')
						});
		},
	getMydata:function(){
		return $('body').data();
		},
	mouseXY:function(){
		var mouseXY=[];
		$(document).bind('mousemove',function(e){ 
			mouseXY[0]=e.pageX;
			mouseXY[1]=e.pageY;
           });
		return mouseXY;
		},	
	contextMenu:function(jqElem,data,menuName,textLimit){
		  var _this=this
		      ,mXY=_this.mouseXY();
		  
          jqElem
		  .smartMenu(data,{
            name: menuName,
			textLimit:textLimit,
			afterShow:function(){
				var menu=$("#smartMenu_"+menuName);
				var myData=myLib.desktop.getMydata(),
		            wh=myData.winWh;//获取当前document宽高
 				var menuXY=menu.offset(),menuH=menu.height(),menuW=menu.width();
				if(menuXY.top>wh['h']-menuH){
					menu.css('top',mXY[1]-menuH-2);
					}
				if(menuXY.left>wh['w']-menuW){
					menu.css('left',mXY[0]-menuW-2);
					}	
				}
           });
		  $(document.body).click(function(event){
			event.preventDefault(); 			  
			$.smartMenu.hide();
						  });
		}	
	}

? 完整源码下载⬇

GitHub 地址:https://github.com/wanghao221/moyu

到此这篇关于HTML实现仿Windows桌面主题特效的实现的文章就介绍到这了,更多相关HTML仿Windows桌面内容请搜索三水点靠木以前的文章或继续浏览下面的相关文章,希望大家以后多多支持三水点靠木!

 
HTML / CSS 相关文章推荐
利用CSS3的flexbox实现水平垂直居中与三列等高布局
Sep 12 HTML / CSS
利用css3-animation实现逐帧动画效果
Mar 10 HTML / CSS
CSS Houdini实现动态波浪纹效果
Jul 30 HTML / CSS
CSS3 实现倒计时效果
Nov 25 HTML / CSS
canvas烟花特效锦集
Jan 17 HTML / CSS
html5 的a标签 Href 拨电话的写法
Nov 04 HTML / CSS
HTML5 Notification(桌面提醒)功能使用实例
Mar 17 HTML / CSS
HTML5所有标签汇总及标签意义解释
Mar 12 HTML / CSS
HTML5高仿微信聊天、微信聊天表情|对话框|编辑器功能
Apr 23 HTML / CSS
详解h5页面在不同ios设备上的问题总结
Mar 01 HTML / CSS
CSS精灵图的原理与使用方法介绍
Mar 17 HTML / CSS
css实现左上角飘带效果的完整代码
Mar 18 HTML / CSS
CSS 实现角标效果的完整代码
Jun 28 #HTML / CSS
CSS SandBox应用场景及常见问题
CSS的calc函数用法小结
Jun 25 #HTML / CSS
flex布局中使用flex-wrap实现换行的项目实践
Jun 21 #HTML / CSS
css3手动实现pc端横向滚动
Jun 21 #HTML / CSS
使用CSS自定义属性实现骨架屏效果
Jun 21 #HTML / CSS
css如何把元素固定在容器底部的四种方式
You might like
php获取给定日期相差天数的方法分析
2017/02/20 PHP
php5对象复制、clone、浅复制与深复制实例详解
2019/08/14 PHP
学习javascript,实现插入排序实现代码
2011/07/31 Javascript
Jquery提交表单 Form.js官方插件介绍
2012/03/01 Javascript
10个基于浏览器的JavaScript调试工具分享
2013/02/07 Javascript
Json字符串转换为JS对象的高效方法实例
2013/05/01 Javascript
完美解决IE低版本不支持call与apply的问题
2013/12/05 Javascript
什么是cookie?js手动创建和存储cookie
2014/05/27 Javascript
jquery控制背景音乐开关与自动播放提示音的方法
2015/02/06 Javascript
移动手机APP手指滑动切换图片特效附源码下载
2015/11/30 Javascript
JS上传组件FileUpload自定义模板的使用方法
2016/05/10 Javascript
JavaScript中日期函数的相关操作知识
2016/08/03 Javascript
详解js中call与apply关键字的作用
2016/11/21 Javascript
JS实现问卷星自动填问卷脚本并在两秒自动提交功能
2020/06/17 Javascript
Node使用Sequlize连接Mysql报错:Access denied for user ‘xxx’@‘localhost’
2018/01/03 Javascript
基于Node.js实现压缩和解压缩的方法
2018/02/13 Javascript
mint-ui在vue中的使用示例
2018/04/05 Javascript
解决Mac下安装nmp的淘宝镜像失败问题
2018/05/16 Javascript
vue路由前进后退动画效果的实现代码
2018/12/10 Javascript
nodejs基础之常用工具模块util用法分析
2018/12/26 NodeJs
JS实现求5的阶乘示例
2019/01/21 Javascript
微信小程序自定义tabbar custom-tab-bar 6s出不来解决方案(cover-view不兼容)
2019/11/01 Javascript
vue 页面跳转的实现方式
2021/01/12 Vue.js
[06:50]DSPL次级职业联赛十强晋级之路
2014/11/18 DOTA
[04:14]从西雅图到上海——玩家自制DOTA2主题歌曲应援TI9
2019/07/11 DOTA
windows下安装Python和pip终极图文教程
2017/03/05 Python
django文档学习之applications使用详解
2018/01/29 Python
python3使用SMTP发送HTML格式邮件
2018/06/19 Python
python mac下安装虚拟环境的图文教程
2019/04/12 Python
在django-xadmin中APScheduler的启动初始化实例
2019/11/15 Python
Python matplotlib画曲线例题解析
2020/02/07 Python
检测浏览器是否支持html5视频的代码
2013/03/28 HTML / CSS
美国爆米花工厂:The Popcorn Factory
2019/09/14 全球购物
化工专业应届生求职信
2013/11/08 职场文书
计算机大学生职业生涯规划书范文
2014/02/19 职场文书
Valheim服务器 Mod修改安装教程 【ValheimPlus】
2022/12/24 Servers