css布局1

181204346272621.jpg

body

<body>
 <header id='title'>
    <h1>Holla</h1>
 </header>

 <div id='content'>
    <div class='sidebar'>
      <h3>Channels</h3>
      <ul>
        <li class='active'>Developers</li>
        <li>Sales</li>
        <li>Marketing</li>
        <li>Ops</li>
      </ul>
    </div>
    <div class='main'>
    </div>
 </div>
</body>

css-body

 body,html{
        margin: 0;
        padding: 0;
     }
     body{
        font-family: Helvetica, Arial, sans-serif;
        font-size: 16px;
        color: #363636;
        background: #d2d2d2;
        line-height: 1.2em;
     }

css-h

h1, h2{
        font-weight: bold;
        text-shadow: 0 1px 1px #fff;
     }
     h1{
        font-size: 24px;
        color: #404040;
     }
     h2{
        font-size: 21px;
        color: #404040;
        margin: 1em 0 0.7em 0;
     }
     h3{
        font-size: 15px;
        color: #404040;
        text-shadow: 0 1px 1px #fff;
     }

css-title

 #title{
        border-bottom: 1px solid #535353;
        overflow: hidden;
        height:  50px;
        line-height: 50px;
        background: #575859;
        
        background: -webkit-gradient(linear, left top, left bottom, from(#575859), to(#272425));
        background: -webkit-linear-gradient(top,#575859,#272425);
        background: -moz-linear-gradient(top,#575859,#272425);
        background: linear-gradient(top,#575859,#272425);
     }
     #title h1{
        color: #fff;
        text-shadow: 0 1px 1px #000;
        margin: 0 10px;
     }

css-content

 #content{
        overflow: hidden;
        /*正文div会覆盖整个页面,但会空出头部50px*/
        position: absolute;
        left: 0;
        right: 0;
        top: 50px;
        bottom: 0;
        /*子元素水平对齐*/
        display: -webkit-box;
        -webkit-box-orient: horizontal;
        -webkit-box-align: stretch;
        -webkit-box-pack: start;
        display: -moz-box;
        -moz-box-orient: horizontal;
        -moz-box-align: stretch;
        -moz-box-pack: start;
     }

css-sidebar

#content .sidebar{
        background: #ededed;
        width: 200px;
        /*此栏有固定高度*/
        -webkit-box-flex: 0;
        -moz-box-flex: 0;
        box-flex: 0;

        overflow: overlay;
    }
    #content .sidebar ul{
      margin: 0;
      padding: 0;
      list-style: none;
    }
    #content .sidebar ul li{
      display: block;
      padding: 10px 10px 7px 20px;
      border-bottom: 1px solid #cdcdcd;
      cursor: pointer;
      -moz-box-shadow: 0 1px 1px #fcfcfc;
      -webkit-box-shadow: 0 1px 1px #fcfcfc;
      box-shadow: 0 1px 1px #fcfcfc;
    }
    #content .sidebar ul li.active{
      color: #fff;
      text-shadow: 0 1px 1px #46677f;
      -webkit-box-shadow: none;
      -moz-box-shadow: none;

      background: #7bb5db;
      background: -webkit-gradient(linear, left top, left bottom, from(#7bb5db), to(#4775b8));
      background: -webkit-linear-gradient(top, #7bb5db, #4775b8);
      background: -moz-linear-gradient(top, #7bb5db, #4775b8);
      background: linear-gradient(top, #7bb5db, #4775b8);
    }

css-main

#content .main{
      -moz-box-shadow: inset 0 1px 3px #7f7f7f;
      -webkit-box-shadow: inset 0 1px 3px #7f7f7f;
      box-shadow: inset 0 1px 3px #7f7f7f;

      /*希望main可以尽可能地伸展开*/
      -webkit-box-flex: 1;
      -moz-box-flex: 1;
      box-flex: 1;

      overflow: overlay;
      padding: 20px;
    }

转载于:https://www.cnblogs.com/jinkspeng/p/4295705.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值