CSS+DIV 布局 (流体布局&刚性布局)

·         流体布局

<!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>

    <title>Liquid layout</title>

    <style type="text/css">

        #wrapper

        {

            border: solid 1px blue;

           /* width: 720px;*/

            width:85%;

            margin: 0 auto;

        }

        #content

        {

            float: right;

           /* width: 520px;*/

           width:75%;

            border: solid 1px red;

            margin-right: 1px;

        }

        #mainContent

        {

            float: left;

            /*width: 320px;*/

            width:66%;

            border: solid 1px red;

        }

        #secondaryContent

        {

            float: right;

           /* width: 180px;*/

           width:31%;    /* mainNav div 一样宽*/

            border: solid 1px green;

        }

        #mainNav

        {

            float: left;

            /*width: 180px;*/

            width:23%;

            padding-top: 20px;

            padding-bottom: 20px;

            border: solid 1px black;

            margin-left: 1px;

        }

        #footer

        {

            border: solid 1px yellow;

            clear: both;

        }

        #footer p

        {

            text-align: center;

            font-weight: bold;

        }

    </style>

</head>

<body>

    <div id="wrapper">

        <div id="branding">

            <h1 style="text-align: center; border-bottom: solid 1px black">

                Liquid layout</h1>

        </div>

        <div id="content">

            <div id="mainContent">

                Your application's run-time performance-its speed-is one of its most visible and

                critical characteristics. Developing high-performance software that meets the expectations

                Your application's run-time performance-its speed-is one of its most visible and

                critical characteristics. Developing high-performance software that meets the expectations

            </div>

            <div id="secondaryContent">

                Your application's run-time performance-its speed-is one of its most visible and

                critical characteristics. Developing high-performance software that meets the expectations

                Your application's run-time performance-its speed-is one of its most visible and

                critical characteristics. Developing high-performance software that meets the expectations

            </div>

        </div>

        <div id="mainNav">

            <ul>

                <li><a href="#">Menu1</a>

                    <ul>

                        <li>Sub1</li>

                        <li>Sub2</li>

                        <li>Sub3</li>

                    </ul>

                </li>

                <li>Menu2</li>

                <li>Menu3</li>

            </ul>

        </div>

        <div id="footer">

            <p>

                Footer Text</p>

        </div>

    </div>

</body>

</html>

 

效果:https://p-blog.csdn.net/images/p_blog_csdn_net/cooleader320/EntryImages/20091001/image001633900350493281250.png

 

 

 

 

 

刚性布局:
<!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>

    <title>Elastic layout</title>

    <style type="text/css">

        /*

            the default font size on most browsers is 16px

            1em roughly equals 10px

        */

        body

        {

          font-size:62.5%;/*1em, 10/16~=62.5%*/

          }

        #wrapper

        {

            border: solid 1px blue;

            width: 72em;

           /* width:720px;*/

            margin: 0 auto;

        }

        #content

        {

            float: right;

            width: 52em;

             /*   width:520px;*/

            border: solid 1px red;

            margin-right: 1px;

        }

        #mainContent

        {

            float: left;

            width: 32em;

            /*width:320px;*/

            border: solid 1px red;

        }

        #secondaryContent

        {

            float: right;

            width: 18em;

          /* width:180px;*/

            border: solid 1px green;

        }

        #mainNav

        {

            float: left;

            width: 18em;

         /*   width:180px;*/

            padding-top: 20px;

            padding-bottom: 20px;

            border: solid 1px black;

            margin-left: 1px;

        }

        #footer

        {

            border: solid 1px yellow;

            clear: both;

        }

        #footer p

        {

            text-align: center;

            font-weight: bold;

        }

    </style>

</head>

<body>

    <div id="wrapper">

        <div id="branding">

            <h1 style="text-align: center; border-bottom: solid 1px black">

                Liquid layout</h1>

        </div>

        <div id="content">

            <div id="mainContent">

                Your application's run-time performance-its speed-is one of its most visible and

                critical characteristics. Developing high-performance software that meets the expectations

                Your application's run-time performance-its speed-is one of its most visible and

                critical characteristics. Developing high-performance software that meets the expectations

            </div>

            <div id="secondaryContent">

                Your application's run-time performance-its speed-is one of its most visible and

                critical characteristics. Developing high-performance software that meets the expectations

                Your application's run-time performance-its speed-is one of its most visible and

                critical characteristics. Developing high-performance software that meets the expectations

            </div>

        </div>

        <div id="mainNav">

            <ul>

                <li><a href="#">Menu1</a>

                    <ul>

                        <li>Sub1</li>

                        <li>Sub2</li>

                        <li>Sub3</li>

                    </ul>

                </li>

                <li>Menu2</li>

                <li>Menu3</li>

            </ul>

        </div>

        <div id="footer">

            <p>

                Footer Text</p>

        </div>

    </div>

</body>

</html>

效果:

https://p-blog.csdn.net/images/p_blog_csdn_net/cooleader320/EntryImages/20091001/image002633900350494062500.png

 

 

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值