CSS網頁布局入門教程6:左列固定,右列寬度自適應

來源:互聯網
上載者:User

在實際應用中,有時候需要左欄固定寬度,右欄根據瀏覽器視窗大小自動適應,在CSS中實現這樣的布局方式是簡單可行的,只需在設定左欄的寬度即可,如上例中左右欄都採用了百分比實現了寬度自適應,而我們只需要將左欄寬度設定為固定值,右欄不設定任何寬度值,並且右欄不浮動,代碼如下: 複製代碼 代碼如下:#left {
background-color: #E8F5FE;
border: 1px solid #A9C9E2;
float: left;
height: 300px;
width: 200px;
}
#right {
background-color: #F2FDDB;
border: 1px solid #A5CF3D;
height: 300px;
}

這樣,左欄將呈現100%的寬度,而右欄將根據瀏覽器視窗大小自適應。 xmlns="http://www.w3.org/1999/xhtml">


左列——固定(AA25.CN)右列——寬度自適應(AA25.CN)

相關文章

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.