前端学习笔记-Flex布局

近日在项目开发中遇到Flex布局,作为前端基础布局,此处整理下笔记

display:flex 多栏多列布局浏览器支持情况:火狐直接支持w3c无前缀写法,谷歌和opera支持-webkit- 前缀写法,比较适合移动端开发使用,

display:flex 这个牛逼的css3布局属性,遗憾的是只有谷歌和火狐支持,
中国人常用的手机上的浏览器几乎全军覆没,UC浏览器不支持,安卓4.1.1和之前版本手机自带的浏览器也不支持,微信自带浏览器也不支持。

 

 

话不多说,先上代码:

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Flex布局</title>
<style type="text/css">
html, body{
height: 100%;
width: 100%;
margin: 0;
}
.main {
display: flex;
height: 100%;
}
.header {
height: 60px;
}

.left-div {
width: 200px;
background-color: #ad7285;
}

.left-div.open {
margin-left: 0px;
}

.left-div.close {
margin-left: -180px;
}

.left-div .left-header{
border-bottom-width: 1px;
border-bottom-color: #ad7285;
border-bottom-style: solid;
display: flex;
}

.left-div .left-header .op-but {
height: 60px;
width: 60px;
}


.left-div .left-header .op-but:hover{
background-color: blueviolet;
}

.left-div .left-header .title {
width: auto;
color: white;
width: 180px;
font-size: 10px;
}

.left-div .left-content {
height: auto;
bootom: 0px;
}

.right-div {
width: 100%;
min-width: 500px;
}

.right-div .right-header{
background-color: #349ce1;
border-bottom-width: 1px;
border-bottom-color: #a2a3a6;
min-width: 500px;
}
.right-div .right-header .title {
text-align: center;
height: 28px;
}
.right-div .right-header .title ul {
padding-left: 0;
background-color: #f5f8fa;
list-style: none;
display: inline-flex;
height: 28px;
margin-top: 13px;
}
.right-div .right-header .title li {
border-width: 1px;
border-style: solid;
border-color: #a2a3a6;
display: inline-block;
padding: 2px 6px 2px 6px;
}

.right-div .right-header .title li.left {
border-top-left-radius: 5px;
}

.right-div .right-header .title li.center {
display: inline-block;
border-left-width: 0px;
border-right-width: 0px;
}
.right-div .right-header .title li.right {
border-top-right-radius: 5px;
}

.right-div .right-header .title li.active {
background-color: #ffffff;
border-bottom-width: 0px;
}
</style>

</head>

<body>
<div class="main">
<div id="leftDiv" class="left-div">
<div class="header left-header">
<div class="title">
</div>
<div id="opDiv" class="op-but open">

</div>
</div>
<div class="left-content">

</div>
</div>

<div class="right-div">
<div class="header right-header">
<div class="title">
</div>
</div>

</div>
</div>

</body>
</html>

  效果如下:

 

 

本文参考地址:http://www.ruanyifeng.com/blog/2015/07/flex-grammar.html

posted @ 2015-08-25 14:27  Trey  阅读(1188)  评论(0编辑  收藏  举报