CSS Layout

CSS Layout 是对上下左右布局的一个简单封装,主要针对自己项目里面方便使用。

坚持组合大于继承的原则,复杂的布局也是由简单布局组成的,当你用习惯了,完全在布局上面不用再去写CSS 啦~

所以不习惯margin/padding-top/right/bottom/left-*的同学可以忽略。

大家可以使用免费cdn 做测试: https://gitcdn.xyz/repo/wz2cool/css_layout/0.1/dist/layout.min.css

(PS: 非前端专攻人士,至于你们觉得好不好,反正我是用的挺爽的_

项目地址:https://github.com/wz2cool/css_layout

.fill

填充父节点全部空间。

.fill-height

填充父节点高度空间。

.fill-width

填充父节点宽度空间。

.float-right

向右浮动。

.float-left

向左浮动。

.margin-/top/right/bottom/left-xx

margin 的上下左右

.padding-/top/right/bottom/left-xx

padding 的上下左右

.horizontal-container

.fill-right

<div class="horizontal-container fill-right" style="height: 100px;">
<div class="left-panel fill-height" style="background: #EE91AD; width: 150px;">
left panel (auto)
</div>
<div class="right-panel fill-height" style="background: #7171D1;">
right panel (fill rest)
</div>
</div>

在线demo

.fill-left

<div class="horizontal-container fill-left" style="height: 100px;">
<div class="right-panel fill-height" style="background: #7171D1; width: 150px;">
right panel (auto)
</div>
<div class="left-panel fill-height" style="background: #EE91AD;">
left panel (fill rest)
</div>
</div>

在线demo

.vertical-container

.fill-bottom

<div class="vertical-container fill-bottom" style="height: 400px;">
<div class="top-panel" style="background: #EE91AD; height: 100px;">
top panel (auto)
</div>
<div class="bottom-panel" style="background: #7171D1;">
bottom panel (fill rest)
</div>
</div>

在线demo

.fill-top

<div class="vertical-container fill-top" style="height: 400px;">
<div class="top-panel" style="background: #EE91AD; ">
top panel (fill rest)
</div>
<div class="bottom-panel" style="background: #7171D1;height: 100px;">
bottom panel (auto)
</div>
</div>

在线demo

complex hor-ver layout

<div class="vertical-container fill-bottom" style="height:300px;">
<div class="top-panel">
top (auto)
</div>
<div class="bottom-panel">
<!-- need fill height width -->
<div class="vertical-container fill-top fill">
<div class="top-panel">
<div class="left-panel fill-height">
left (auto)
</div>
<div class="right-panel fill-height">
<div class="horizontal-container fill-left fill">
<div class="right-panel fill-height">
right(auto)
</div>
<div class="left-panel fill-height">
center
</div>
</div>
</div>
</div>
</div>
<div class="bottom-panel">
bottom panel (auto)
</div>
</div>
</div>

.center-container

.center-horizontal

<div class="center-container center-horizontal" style="background: #EE91AD; width: 200px; height: 50px">
<div class="center-panel">
center item
</div>
</div>

.center-vertical

<div class="center-container center-vertical" style="background: #EE91AD; width: 200px; height: 50px">
<div class="center-panel">
center item
</div>
</div>

ver-hor center

<div class="center-container center-vertical" style="background: #EE91AD; width: 200px; height: 50px">
<div class="center-panel">
<div class="center-container center-horizontal">
<div class="center-panel">
<span>*</span> center item
</div>
</div>
</div>
</div>

仿照葡萄城举例

正好看到别人举例的一个布局: http://www.cnblogs.com/powertoolsteam/p/combine-flexbox-and-css-grids-for-layouts.html

我们立刻用我们的方法实现了一下: 在线demo

关注我 ##

最后大家可以关注我和 css_layout项目 _

Follow @wz2cool Star Fork

简单CSS 布局的更多相关文章

  1. 简单CSS布局留用

    1.导航栏固定显示代码,文字居中,z-index header{ position: fixed; top: 0px; left: 10%; width: 80%; height: 80px; bor ...

  2. (转)div+css 布局经验 - 最简单的 = 最不变形的(原创技巧)

    站酷几年了 一直饱受其恩泽 尤为感激 一直想奉献些什么 但是苦于水平 苦于奔波 今天静下心来 为大家奉献下 自己的div+css 经验 ,以下观点只代表 深海个人立场 希望为初学者提供一条" ...

  3. div+css 布局经验 - 最简单的 = 最不变形的(原创技巧)

    站酷几年了 一直饱受其恩泽 尤为感激 一直想奉献些什么 但是苦于水平 苦于奔波 今天静下心来 为大家奉献下 自己的div+css 经验 ,以下观点只代表 深海个人立场 希望为初学者提供一条" ...

  4. [CSS布局]简单的CSS三列布局

    前言 公司终于可以上外网了,近期在搞RN的东西,暂时脑子有点晕,等过段时间再来写点总结.倒是最近有个新学前端的同学经常会问一些基础知识,工作空闲写了小Demo给他看,全是很基础的知识,纯粹是顺便记录在 ...

  5. 界面设计技法之css布局

    css布局之于页面就如同ECMAScript之于JS一般,细想一番,html就如同语文,css就如同数学,js呢,就是物理,有些扯远,这里就先不展开了. 回到主题,从最开始的css到如今的sass(l ...

  6. CSS布局 - 三栏布局

    CSS布局技术可谓是前端技术中最基础的技术,就是因为基础,所以我认为要更加熟练,深入的去掌握,去梳理. 一. 传统 ---> 浮动实现的三栏布局 采用浮动实现的三栏布局有以下特点及注意事项: · ...

  7. CSS 布局

    近日开发中,总感觉页面布局方面力不从心.以前也曾学过这方面的内容,但是不够系统,因此我打算整理一下. 在web 页面中一般有 table 和 css+div 两种布局方式. 其中css+div 又分为 ...

  8. CSS布局经典—圣杯布局与双飞翼布局

    在我之前的博客网页整体布局完全剖析-剖完你不进来看一下么?中总结单列.两列.三列固宽与变宽布局,我还以为已经囊括了所有经典的网页布局方法了呢,当然除了CSS3的弹性盒模型没有涉及到,现在看来确实是自己 ...

  9. CSS篇之DIV+CSS布局

    <div></div> div与其他标签一样,也是一个XHTML所支持的标签. div是XHTML中指定的,远门用于布局设计的容器标记. 简单的CSS布局 头部 内容 页脚 & ...

随机推荐

  1. 【Ganglia】集群监控系统搭建

    参考博客 www.cnblogs.com/atomicbomb/p/6726119.html 操作系统 centos7  机器两台 一. 配置软件环境 操作步骤: 使用yum安装方式安装所需基础依赖包 ...

  2. [js高手之路]设计模式系列课程-发布者,订阅者重构购物车

    发布者订阅者模式,是一种很常见的模式,比如: 一.买卖房子 生活中的买房,卖房,中介就构成了一个发布订阅者模式,买房的人,一般需要的是房源,价格,使用面积等信息,他充当了订阅者的角色 中介拿到卖主的房 ...

  3. 数据结构-单向链表 C和C++的实现

    数据结构,一堆数据的存放方式. 今天我们学习数据结构中的 链表: 链表的结构: 链表是一种特殊的数组,它的每个元素称为节点,每个节点包括两个部分: 数据域:存放数据,此部分与数组相同 指针域:存放了下 ...

  4. 安装lvs过程

    linux我是最小化安装的mini,安装完成后搭建本地yum,首先安装Development Tools开发工具组 1)在各服务器上修改主机名: [root@LVS1 ~]# hostname LVS ...

  5. XMind与MindManager哪个好(网易云课堂老师:Array老师讲解稿)

    XMind与MindManager哪个好 作者:网易云课堂老师:Array老师讲解稿 思维导图是一种将放射性思考具体化的方法,可以将人们的创造性思维及时捕捉并呈现,深受商业人士的喜爱.目前,XMind ...

  6. Keil提示premature end of file错误 无法生成HEX文件

    今天舍友在使用Keil UV4的时候遇到一个问题:Keil提示premature end of file,无法生成hex文件. 代码是没有错误的.那么问题就出在设置上面了. 百度了一圈,发现很少人解答 ...

  7. LVS-DR实现web调度模式

    author:JevonWei 版权声明:原创作品 实现LVS-DR调度web模式 拓扑环境 网络环境 RS1 RIP 192.168.198.138/24 VIP 192.168.198.100/3 ...

  8. 使用CXF开发JAX-RS类型的WebService

    1.JAXRSServerFactoryBean编程方式 访问方式:http://localhost:8080/cxf_spring_rest_server/ws/rest/student/query ...

  9. indexOf和lastIndexOf方法

    lastIndexOf 方法: 返回 String 对象中子字符串最后出现的位置. strObj.lastIndexOf(substring[startindex]) 参数:strObj必选项.Str ...

  10. Python 多线程库总结

    多线程库总结 基于线程的并行性 threading模块 下面是一些基础函数,函数包括: 函数 threading.active_count() threading.current_thread() t ...