原文: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>

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

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

  1. CSS3+HTML5特效9 - 简单的时钟

    原文:CSS3+HTML5特效9 - 简单的时钟 效果演示(加快了100倍)         实现原理 利用CSS3的transform-origin 及 transform 完成以上效果. 代码及说 ...

  2. CSS自适应布局(左右固定 中间自适应或者右侧固定 左侧自适应)

    经常在工作中或者在面试中会碰到这样的问题,比如我想要个布局 右侧固定宽度 左侧自适应 或者 三列布局 左右固定 中间自适应的问题. 下面我们分别来学习下,当然我也是总结下而已,有如以下方法: 一: 右 ...

  3. css3+html5特效-向上滑动

    css+html5特效-向上滑动 效果描述:切换的下拉和上拉状态 鼠标悬浮:下拉鼠标离开:上拉 /*外容器设置*/ .box1{position:relative;top:100px;left:100 ...

  4. CSS3+HTML5特效7 - 特殊的 Loading 效果

    效果如下     实现原理: 利用CSS3的@keyframes规则创建动画效果: 使用CSS3的animation效果完成滚动切换. 代码说明: 样式表中@-webkit-keyframes及@ke ...

  5. CSS3+HTML5特效4 - 横向无缝滚动

    先看例子 This is a test 1. This is a test 2. This is a test 3. This is a test 4. This is a test 5. This ...

  6. CSS3+HTML5特效3 - 纵向无缝滚动

    老惯例,先看例子. This is a test 1. This is a test 2. This is a test 3. This is a test 4. This is a test 5. ...

  7. CSS3+HTML5特效6 - 闪烁的文字

    先看效果 abcd 这个效果也比较简单,利用keyframes对文字的大小.透明度及颜色做循环显示. CSS <style> @-webkit-keyframes flash { 0%{ ...

  8. CSS3+HTML5特效5 - 震动的文字

    先看效果(把鼠标移上去看看) abcd 这个效果很简单,就是移动文字的位置模拟出震动的效果. Css <style> @-webkit-keyframes shake { 0%{ -web ...

  9. CSS3+HTML5特效2 - 翻转效果

    先看效果,鼠标移上去看看. back front 1. 本实例需要以下元素 a. 容器BOX b. 默认显示元素FRONT c. 翻转显示元素BACK 2. 容器BOX的Height为200px,Wi ...

随机推荐

  1. std::string 不支持back

    string  s = "abc"; if ( s.back() == 'c' ) .... , 不支持back, 但是用VS2010好吧 后来发现, string的back/fr ...

  2. DisplayContent、StackBox、TaskStack笔记

    文章仅零散记录自己的一点理解,仅供自己參考. 每一个显示设备,都有一个Display对象,DisplayManagerService专门管理这些Display. 1.DisplayContent() ...

  3. Mongodb安装和配置

    Mongodb之安装配置 安装 Mongodb的下载地址为Mongodb官网.下载时.你能够选择是安装包或者是压缩包. 下载完毕后.双击安装包并安装. 安装完毕后.你能够在安装文件夹看到下图中所见的文 ...

  4. Storm基础知识

    上一篇文章我们介绍一个简单的Storm起源,今天我去学习Storm一些主要的知识,他的基本使用基本的了解.幸运的是,,不是太困难,假设我们理解Hadoop的MapReduce模型的话.看这个也是很类似 ...

  5. iOS多用连接、反向协议、安全

    资源 WWDC-2013-Session-708 BlackHat-US-2014-"It Just (Net)works" Understanding Multipeer Con ...

  6. Html5用Canvas制作画图板

    需求: 绘制多边形 可填充颜色 可设置文字 可移动,可删除 鼠标按住后,抬起之前线段应该尾随鼠标当前位置 可与后台方便的进行数据交互,保存到后台,或将数据从后台取到前台显示对应的图形 思考: 第一想到 ...

  7. 房费制 它 结账BUG

    声明:以下内容仅仅是对在桌子上的卡与卡表的后面,适合学生的表!     最近,我们已经开始做VB.NET系统重构版,在这里跟大家聊聊我在机房收费系统中发现的漏洞. 在机房收费系统中有这样一个窗口--结 ...

  8. SQL Server 2008性能故障排查(二)——CPU

    原文:SQL Server 2008性能故障排查(二)--CPU 承接上一篇:SQL Server 2008性能故障排查(一)--概论 说明一下,CSDN的博客编辑非常不人性化,我在word里面都排好 ...

  9. html 块状元素 行内元素 内联元素

    块状(Block)类型的元素的width默认为100%,而行内(Inline)类型的元素则是根据自身的内容及子元素来决定宽度. 块元素(block element) address - 地址 bloc ...

  10. C#+Mapxtreme 实现一些GIS系统基本的功能

    此程序包括了mapxtreme地图相关基本功能的演示其中包括 鹰眼地图,图层控制,发达,缩小,平移地图,地图模糊查询,中点工具,距离测量工具,面积测量工具,图元信息查看工具.适合于企业级开发,可以为您 ...