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


实现原理
- 使用3个div(一个是顶部栏,一个是左侧栏,一个是右侧栏);
- 使用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>
- 设置了顶部div,height为30px,width为100%,底部有边框的效果;
- 设置了左侧div,top为32px,距离右侧301px,距离底部1px,width为auto的效果;
- 设置了右侧div,top为31px,width为300px,距离底部1px,左侧有边框的效果;
- 设置了用于点击切换效果的区域,top为49%,width为15px,height为50px,距离右侧301px,同时设置左上及左下为圆角效果;
- 设置用于标识右侧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 - 顶部和右侧固定,左侧随窗口变化的布局的更多相关文章
- CSS3+HTML5特效9 - 简单的时钟
原文:CSS3+HTML5特效9 - 简单的时钟 效果演示(加快了100倍) 实现原理 利用CSS3的transform-origin 及 transform 完成以上效果. 代码及说 ...
- CSS自适应布局(左右固定 中间自适应或者右侧固定 左侧自适应)
经常在工作中或者在面试中会碰到这样的问题,比如我想要个布局 右侧固定宽度 左侧自适应 或者 三列布局 左右固定 中间自适应的问题. 下面我们分别来学习下,当然我也是总结下而已,有如以下方法: 一: 右 ...
- css3+html5特效-向上滑动
css+html5特效-向上滑动 效果描述:切换的下拉和上拉状态 鼠标悬浮:下拉鼠标离开:上拉 /*外容器设置*/ .box1{position:relative;top:100px;left:100 ...
- CSS3+HTML5特效7 - 特殊的 Loading 效果
效果如下 实现原理: 利用CSS3的@keyframes规则创建动画效果: 使用CSS3的animation效果完成滚动切换. 代码说明: 样式表中@-webkit-keyframes及@ke ...
- 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 ...
- 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. ...
- CSS3+HTML5特效6 - 闪烁的文字
先看效果 abcd 这个效果也比较简单,利用keyframes对文字的大小.透明度及颜色做循环显示. CSS <style> @-webkit-keyframes flash { 0%{ ...
- CSS3+HTML5特效5 - 震动的文字
先看效果(把鼠标移上去看看) abcd 这个效果很简单,就是移动文字的位置模拟出震动的效果. Css <style> @-webkit-keyframes shake { 0%{ -web ...
- CSS3+HTML5特效2 - 翻转效果
先看效果,鼠标移上去看看. back front 1. 本实例需要以下元素 a. 容器BOX b. 默认显示元素FRONT c. 翻转显示元素BACK 2. 容器BOX的Height为200px,Wi ...
随机推荐
- Sublime Text 3 搭建Go开发环境(Windows)
一.安装GO 如果已经环境已经配置好,这一步省略.... 1.下载并安装go sdk 2.配置环境变量 (1). 新建 变量名:GOBIN 变量值 :F:\Go\bin (2). 新建 变量名:GOA ...
- OpenGL中shader使用
学了接近一个月的OpenGL,最终要排上用场了...好吧,就从学到的shader(着色器)开刀吧. 先简单的介绍shader,shader事实上是显卡的功能,就是利用显卡的GPU去做图像处理的工作,而 ...
- ehCache浅谈(转)
ehcache FAQ中提到 Remember that a value in a cache element is globally accessible from multiple threads ...
- 本文摘录 - Infobright
背景 论文 Brighthouse: AnAnalytic Data Warehouse for Ad-hoc Queries.VLDB 2008 brighthouse它是一个面向列的数据仓库.在数 ...
- weighted Kernel k-means 加权核k均值算法理解及其实现(一)
那就从k-means开始吧 对于机器学习的新手小白来说,k-means算法应该都会接触到吧.传统的k-means算法是一个硬聚类(因为要指定k这个参数啦)算法.这里利用百度的解释 它是数据点到原型的某 ...
- opengl编程指南
第一章 opengl简单介绍 1.1 什么是opengl opengl是图形硬件的一种软件接口. 1>渲染(rendering)是计算机依据模型创建图像的过程. 2>模型(m ...
- 杭州电 1052 Tian Ji -- The Horse Racing(贪婪)
http://acm.hdu.edu.cn/showproblem.php? pid=1052 Tian Ji -- The Horse Racing Time Limit: 2000/1000 MS ...
- java中 try return finally return(转)
finally块里面的代码一般都是会执行的,除非执行 System.exit(int),停止虚拟机,断电. 1.若try代码块里面有return ,假设要return 的值 是A,A为基本类型或者被f ...
- HTTP 请求报文 响应报文(转)
引言 超文本传输协议(HTTP,HyperText Transfer Protocol)是互联网上应用最为广泛的一种网络协议.所有的WWW文件都必须遵守这个标准.设计HTTP最初的目的是为了提供一种发 ...
- 熟人Dubbo 系列1-Dubbo什么
Dubbo阿里巴巴内部SOA治理方案和服务的核心框架.每天2000+ 个服务提供3,000,000,000+ 次訪问量支持,并被广泛应用于阿里巴巴集团的各成员网站.Dubbo自2011年开源后,已被很 ...