CSS 左邊固定寬度右邊自適應寬度總結__css

來源:互聯網
上載者:User
CSS 左邊固定寬度右邊自適應寬度總結

兩個div並排,左邊的寬度固定,右邊自適應。 我的左邊是導覽列,右邊也分上下兩部分。

整個頁面:

html,body{    margin:0px;    height:100%;}

1、左側導覽列,使用position: absolute;

.main-sidebar{    position: absolute;    top: 0;    left: 0;    height: 100%;    min-height: 100%;    width: 240px;    background-color: #222d32;}

2、右邊

.right{    margin-left: 240px;    height:100%;     font:normal 20px/24px 'MicroSoft YaHei';}

右側又分上下兩部分,固定上面的Height即可:

.topbar{    height: 50px;     border: 1px solid #005580}

還可以通過float:left的屬性。


相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.