CSS3+HTML5特效8 - 顶部和右侧固定,左侧随窗口变化的布局

简介: 原文:CSS3+HTML5特效8 - 顶部和右侧固定,左侧随窗口变化的布局 效果演示     实现原理 使用3个div(一个是顶部栏,一个是左侧栏,一个是右侧栏); 使用checkbox作为判断是否显示和隐藏右侧栏,点击显示和隐藏label实现最终效果。
+关注继续查看
原文:CSS3+HTML5特效8 - 顶部和右侧固定,左侧随窗口变化的布局

效果演示

 

 

实现原理

  1. 使用3个div(一个是顶部栏,一个是左侧栏,一个是右侧栏);
  2. 使用checkbox作为判断是否显示和隐藏右侧栏,点击显示和隐藏label实现最终效果。

 

代码说明

css

<style>
body {
  font-family:"Microsoft YaHei",arial,sans-serif;
  margin: 0px;
  padding: 0px;
  color: #666;
}

ul {
  margin:0;
  padding:0;
  list-style-type:none;
}

.topPanel{
	position: fixed;
	top: 0px;
	left: 0px;
	height: 30px;
	width: 100%;
	border-top: 1px solid #e0e0e0;
	border-bottom: 1px solid #e0e0e0;
	background: #F0FFFF;
}

.topPanel div{
	display: inline-block;
	padding: 3px 20px 0px 3px;
	height: 27px;
}

.splitPanel{
	position: fixed;
	top: 49%;
	width: 15px;
	height: 50px;
	right: 301px;
	background: #1E90FF;
	cursor: pointer;
	border-top-left-radius: 10px;
	border-bottom-left-radius: 10px;
	z-index: 9999;
}

.showHideRightPanelChk {
	display: none;
}

.showHideRightPanelChk:checked ~ .rightPanel {
	display: none;
}

.showHideRightPanelChk:checked ~ .splitPanel {
	right: 0px;
	background: #FFC125;
}

.showHideRightPanelChk:checked ~ .splitPanel label{
	right: 0px;
}

.showHideRightPanelChk:checked ~ .splitPanel label:nth-child(1){
	margin: 20px 0px 0px 6px;
	transform: rotate(315deg);
	-webkit-transition:1s all ease;
	transition:1s all ease;
}

.showHideRightPanelChk:checked ~ .contentPanel {
    right: 0px;
}

.splitMark{
	margin: 20px 0px 0px 3px;
	width: 5px;
	height: 5px;
	border-top: 2px #fff solid;
	border-left: 2px #fff solid;
	transform: rotate(135deg);
	display: inline-block;
	-webkit-transition:1s all ease;
	transition:1s all ease;
}

.splitBorder{
	position: fixed;
	top: 49%;
	width: 15px;
	height: 50px;
	right: 301px;
}

.rightPanel{
	position: fixed;
	top: 31px;
	right: 0px;
	width: 299px;
	bottom: 1px;
	border-left: 1px solid #e0e0e0;
	padding: 1px 1px 1px 1px;
}

.rightPanel div{
	display: inline-block;
	margin: 0px 0px 14px 0px;
}

.contentPanel{
	position: fixed;
	top: 32px;
	left: 0px;
	right: 301px;
	bottom: 1px;
	width: auto;
	background: #FFFFF0;
}
</style>

  

  1. 设置了顶部div,height为30px,width为100%,底部有边框的效果;
  2. 设置了左侧div,top为32px,距离右侧301px,距离底部1px,width为auto的效果;
  3. 设置了右侧div,top为31px,width为300px,距离底部1px,左侧有边框的效果;
  4. 设置了用于点击切换效果的区域,top为49%,width为15px,height为50px,距离右侧301px,同时设置左上及左下为圆角效果;
  5. 设置用于标识右侧div显示和隐藏效果的样式。

 

html

<div>
	<input id="showHideRightPanel" class="showHideRightPanelChk" type="checkbox">
	<div class="topPanel">
		<div>Top panel</div>
	</div>
	<div class="contentPanel">
		<div>Content
		Content Content Content Content Content Content Content Content Content Content Content Content Content Content Content Content Content Content Content Content Content Content Content Content Content Content Content </div>
	</div>
	<div class="splitPanel">
		<label for="showHideRightPanel" class="splitMark"></label>
		<label for="showHideRightPanel" class="splitBorder"></label>
	</div>
	<div class="rightPanel">
		<div>
			<ul>
				<li>Right panel</li>
			</ul>
		</div>
	</div>
</div>

 运行后,就可以看见效果了。

 

 

目录
相关文章
|
9月前
|
前端开发
CSS 05 transition特效
transition-property 过渡属性,默认值为all transition-duration 过渡持续时间,默认时间为0s transition-timing-function 过渡函数,默认ease函数,还有ease-out(先快后慢)、ease-in(先慢后快)、linear(匀速)等等函数 transition-delay 过渡延迟时间,默认0s <div class="ceng"> </div> .ceng{ width:100px; height:100px; background-color:pink; cursor:point
|
11月前
|
前端开发
CSS特效之丑蘑菇
CSS特效之丑蘑菇
CSS特效之丑蘑菇
|
11月前
|
前端开发
HTML+CSS+JS实现卡通人物C罗ui特效
2022年卡塔尔世界杯(英语:FIFA World Cup Qatar 2022)是第二十二届世界杯足球赛,是历史上首次在卡塔尔和中东国家境内举行、也是第二次在亚洲举行的世界杯足球赛。除此之外,卡塔尔世界杯还是首次在北半球冬季举行、首次由从未进过世界杯决赛圈的国家举办的世界杯足球赛
HTML+CSS+JS实现卡通人物C罗ui特效
|
12月前
|
前端开发
CSS特效集锦(9款 , 总有一款是你喜欢的)
主要是: 穿越时空特效, 图片放大镜, 3D相册, 立方体相册, 昼夜更替特效, 飘雪, 七彩雨, 签名生成器, 水波纹动画等
CSS特效集锦(9款 , 总有一款是你喜欢的)
|
12月前
|
前端开发
|
12月前
|
前端开发 JavaScript 程序员
基于H5+css+JavaScript实现旋转水滴网页加载特效
基于H5+css+JavaScript实现旋转水滴网页加载特效
162 0
基于H5+css+JavaScript实现旋转水滴网页加载特效
|
12月前
|
前端开发 JavaScript 程序员
基于H5+css+JavaScript实现流光圆环加载特效页面
基于H5+css+JavaScript实现流光圆环加载特效页面
291 0
|
12月前
|
前端开发 JavaScript 程序员
基于H5+css+JavaScript实现经典加载特效
基于H5+css+JavaScript实现经典加载特效
99 0
基于H5+css+JavaScript实现经典加载特效
|
12月前
|
前端开发 JavaScript 程序员
H5+css+JavaScript满屏彩色泡泡小特效(适合表白哦~做完发给让你每天想念的人吧~)
H5+css+JavaScript满屏彩色泡泡小特效(适合表白哦~做完发给让你每天想念的人吧~)
104 0
H5+css+JavaScript满屏彩色泡泡小特效(适合表白哦~做完发给让你每天想念的人吧~)
|
前端开发 容器
用CSS实现超美星空特效
最近真是越来越对CSS感兴趣了,于是再来整一手,夜晚的星星,再配合上皎洁的月光,这唯美的星空,它来了! 今天带领大家,用CSS实现一下,这美丽的星空。
相关产品
云迁移中心
推荐文章
更多