• clear元素的margintop被重置为零


     

    当你使用clear(left & both & right)清理一个浮动元素时,该元素的margin-top会被重置为0。所以为了创建浮动列,并使用footer进行浮动清理时,必须对浮动列(sidebar && content)都指定margin-bottom,最好margin-bottom相同。(Firefox会将margin-top重置0,而IE不重置footer的margin-top)。

    clear-footer

    例如:

    分别在Firefox和IE中运行一下代码,仔细读者会发现页脚(footer)的margin-top在火狐中并没有显示,而在IE中却出现了10像素的上边距。 HTML代码

    <body>

    <div id="wrapper">
        
    <div id="masthead">
            masthead content goes here
        
    </div>
        
    <div id="sidebar">
            sidebar content goes here
        
    </div>
        
    <div id="content">
            main content goes here
            
    <br/>
            main content goes here
        
    </div>
        
    <div id="footer">
            footer
        
    </div>
    </div>

    </body>
    CSS代码
    body {
        margin
    :0; padding:0;
        background-color
    :#FFFFCC;
    }

    #wrapper 
    {
        width
    :800px;
        margin
    :0 auto;
    }

    /*Masthead*/
    #masthead 
    {
        padding
    :10px;
        background
    :#FFCC33;
        margin-bottom
    :10px;
    }

    /*Content*/
    #content 
    {
        float
    :left;
        width
    :60%;
        background
    :#CCCCCC;
    }

    /*Sidebar*/
    #sidebar 
    {
        float
    :right;
        width
    :36%;
        background
    :#999999;
    }

    /*Footer*/
    #footer 
    {
        clear
    :both;
        padding
    :10px;
        background
    :#FFCC33;
    }
  • 相关阅读:
    oracle--角色权限
    oracle--权限的传递
    oracle--少见操作、如何调整dos窗口大小、字符集设置
    oracle--对象权限
    oracle-系统权限管理
    IOS-swift5.1快速入门之旅
    oracle--用户区别sys和system
    JSP基础--EL表达式
    JSP基础--javaBean
    hdu_A Walk Through the Forest ——迪杰特斯拉+dfs
  • 原文地址:https://www.cnblogs.com/rainman/p/1186932.html
Copyright © 2020-2023  润新知