原文: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. Alamofire网络库进阶教程

    本章节由CocoaChina翻译组成员星夜暮晨(博客)翻译自raywenderlich:Intermediate Alamofire Tutorial,敬请勘误. 欢迎回到我们的 Alamofire ...

  2. fcitx

    安装完成后首先面对的问题是全英文无法显示汉字和输入汉字的问题.需要找到光盘上的2个中文支持字体包安装上即可.文件名如下,注意不同版本文件明后面数字部分可能会不同,其代表版本号.下面是Red Hat E ...

  3. 【POJ】The Suspects(裸并查集)

    并查集的模板题,为了避免麻烦,合并的时候根节点大的合并到小的结点. #include<cstdio> #include<algorithm> using namespace s ...

  4. cassandra 服务启动流程

    cassandra 服务启动流程 1.  setup 1)   CassandraDaemon ->main publicstaticvoidmain(String[]args) { insta ...

  5. 【剑指offer】面试题39:深度二叉树

    def TreeDepth1(root): if None == root: return 0 if None == root.left and None == root.right: return ...

  6. FireFox VS Chrome 之 调试篇

    一个完美的调试工具,FireBug! 精确跟踪每一步.仅仅要按下图所看到的,选择"脚本",然后在下方选择脚本所在的文件就可以对该文本的运行进行断点跟踪. 而且仅当一个线程运行结束后 ...

  7. 关于 cookie 使用中遇到的问题

    前段时间在一个项目中涉及到cookie的存取,于是打算封装一个 cookie 的CRUD .按理来说,这本身是一个很简单的问题,不注意的话简单的问题也有大坑. /** * Set or get coo ...

  8. ssl通关的概念(一个)

    在公司最近的项目涉及多种加密.安全.我一直在这方面缺乏经验.很协议仅仅知道是什么概念.用于传输的加密SSL,也煞费苦心.非常easy一件事,折腾了很长一段时间.IT该行啊,真的是.难者不会,与会者困难 ...

  9. 几个cd快速提示

    cd是project师每天都会用到的命令. 今天就来分享几条和cd有关的小技巧 cd 假设你用cd ~来进入当前用户的home文件夹的话,那么能够试试直接敲cd. 相同效果,少敲两下键盘. cd - ...

  10. java它 ------ 图形界面(两)

    <img src="http://img.blog.csdn.net/20150604093446275?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi ...