DIV+CSS左右兩列自適應高度的方法

來源:互聯網
上載者:User

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />

<title>DIV+CSS左右兩列自適應高度的方法-HTMer</title>

<style type="text/css">

.main{500px;overflow:hidden;}

.left{width:100px;background-color:#0CC;margin-bottom:-9999px;padding-bottom:9999px;float:left;}

.right{width:400px;background-color:#F00;float:left;}

</style>

</head>

<body>

<div class="main">

    <div class="left">左側內容1</div>

    <div class="right">右側內容1<br />右側內容2<br />右側內容3</div>

</div>

</body>

</html>

    說明:其實解決DIV+CSS左右兩列高度自適應的方法就是要注意兩點:一是在最外層加上overflow:hidden,然後在左邊列加上margin-bottom:-9999px;padding-bottom:9999px;即可。 原創文章:http://www.blogbus.com/ada-life-logs/231591213.html

相關文章

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.