茄子在线看片免费人成视频,午夜福利精品a在线观看,国产高清自产拍在线观看,久久综合久久狠狠综合

    <s id="ddbnn"></s>
  • <sub id="ddbnn"><ol id="ddbnn"></ol></sub>

  • <legend id="ddbnn"></legend><s id="ddbnn"></s>

    html清除浮動的幾種方法示例
    來源:易賢網(wǎng) 閱讀:1153 次 日期:2014-12-19 11:53:24
    溫馨提示:易賢網(wǎng)小編為您整理了“html清除浮動的幾種方法示例”,方便廣大網(wǎng)友查閱!

    使用display:inline-block會出現(xiàn)的情況:

    1.使塊元素在一行顯示

    2.使內(nèi)嵌支持寬高

    3.換行被解析了

    4.不設置的時候?qū)挾扔蓛?nèi)容撐開

    5.在IE6,7下步支持塊標簽

    由于inline-block屬性換行的時候被解析(有間隙)故解決方法使用浮動float:left/right

    使用浮動時出現(xiàn)的情況:

    1.使塊元素在一行顯示

    2.使內(nèi)嵌元素支持寬高

    3.不設置不寬高的時候?qū)挾扔蓛?nèi)容撐開

    4.換行不被解析(故使用行內(nèi)元素的時候清除間隙的方法可以使用浮動)

    5.元素添加浮動,會脫離文檔流,按照指定的一個方向移動,直到碰到父級的邊界或者另一個浮動元素停止(文檔流是文檔中可顯示對象在排列時所占用的位置)

    代碼如下:

    <!DOCTYPE HTML>

    <html>

    <head>

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

    <title>無標題文檔</title>

    <style>

    div,span{height:100px;background:red;border:1px solid #000; float:left;}

    /*

    inline-block

    1.使塊元素在一行顯示

    2.使內(nèi)嵌支持寬高

    3.換行被解析了

    4.不設置寬度的時候?qū)挾扔蓛?nèi)容撐開

    5.在IE6,7下不支持塊標簽

    浮動:

    1.使塊元素在一行顯示

    2.使內(nèi)嵌支持寬高

    3.不設置寬度的時候?qū)挾扔蓛?nèi)容撐開

    */

    </style>

    </head>

    <body>

    <div class="div1">div1</div>

    <div class="div2">div2</div>

    <span class="span1">span1</span>

    <span class="span2">span2</span>

    </body>

    </html>

    下面的代碼只有box1浮動,則box1,box2重疊一起。兩者都浮動就不會重疊

    代碼如下:

    <!DOCTYPE HTML>

    <html>

    <head>

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

    <title>無標題文檔</title>

    <style>

    .box1{ width:100px;height:100px;background:red; float:left;}

    .box2{ width:200px;height:200px;background:blue; /* float:left;*/}

    </style>

    </head>

    <body>

    <div class="box1"></div>

    <div class="box2"></div>

    </body>

    </html>

    清浮動的方法:

    1.給父級也加浮動(這種情況當父級margin:0 auto;時不居中)

    代碼如下:

    <!DOCTYPE HTML>

    <html>

    <head>

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

    <title>無標題文檔</title>

    <style>

    .box{ width:300px;margin:0 auto;border:10px solid #000; float:left;}

    .div{ width:200px;height:200px;background:red;float:left;}

    /*

    清浮動

    1.給父級也加浮動(不居中了)

    */

    </style>

    </head>

    <body>

    <div class="box">

    <div class="div"></div>

    </div>

    </body>

    </html>

    2.給父級加display:inline-block;(同方法1,不居中。只有IE6,7居中)

    代碼如下:

    <!DOCTYPE HTML>

    <html>

    <head>

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

    <title>無標題文檔</title>

    <style>

    .box{ width:300px;margin:0 auto;border:10px solid #000; display:inline-block;}

    .div{ width:200px;height:200px;background:red;float:left;}

    /*

    清浮動

    1.給父級也加浮動

    2.給父級加display:inline-block

    */

    </style>

    </head>

    <body>

    <div class="box">

    <div class="div"></div>

    </div>

    </body>

    </html>

    3.在浮動元素下加<div class="clear"></div>

    .clear{ height:0px;font-size:0;clear:both;}但是在ie6下,塊元素有最小高度,即當height<19px時,默認為19px,解決方法:font-size:0;或overflow:hidden;

    代碼如下:

    <!DOCTYPE HTML>

    <html>

    <head>

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

    <title>無標題文檔</title>

    <style>

    .box{ width:300px;margin:0 auto;border:10px solid #000;}

    .div{ width:200px;height:200px;background:red;float:left;}

    .clear{ height:0px;font-size:0;clear:both;}

    /*

    清浮動

    1.給父級也加浮動

    2.給父級加display:inline-block

    3.在浮動元素下加<div class="clear"></div>

    .clear{ height:0px;font-size:0;clear:both;}

    */

    </style>

    </head>

    <body>

    <div class="box">

    <div class="div"></div>

    <div class="clear"></div>

    </div>

    </body>

    </html>

    4.在浮動元素下加<br clear="all">

    代碼如下:

    <!DOCTYPE HTML>

    <html>

    <head>

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

    <title>無標題文檔</title>

    <style>

    .box{ width:300px;margin:0 auto;border:10px solid #000;}

    .div{ width:200px;height:200px;background:red;float:left;}

    /*

    清浮動

    1.給父級也加浮動

    2.給父級加display:inline-block

    3.在浮動元素下加<div class="clear"></div>

    .clear{ height:0px;font-size:0;clear:both;}

    4.在浮動元素下加<br clear="all"/>

    */

    </style>

    </head>

    <body>

    <div class="box">

    <div class="div"></div>

    <br clear="all"/>

    </div>

    </body>

    </html>

    5.給浮動元素父級加{zoom:1;}

    :after{content:""; display:block;clear:both;}

    代碼如下:

    <!DOCTYPE HTML>

    <html>

    <head>

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

    <title>無標題文檔</title>

    <style>

    .box{margin:0 auto;border:10px solid #000;}

    .div{ width:200px;height:200px;background:red;float:left;}

    .clear{zoom:1;}

    .clear:after{content:""; display:block;clear:both;}

    /*

    清浮動

    1.給父級也加浮動

    2.給父級加display:inline-block

    3.在浮動元素下加<div class="clear"></div>

    .clear{ height:0px;font-size:0;clear:both;}

    4.在浮動元素下加<br clear="all"/>

    5. 給浮動元素的父級加{zoom:1;}

    :after{content:""; display:block;clear:both;}

    **在IE6,7下浮動元素的父級有寬度就不用清浮動

    haslayout 根據(jù)元素內(nèi)容的大小 或者父級的父級的大小來重新的計算元素的寬高

    display: inline-block

    height: (任何值除了auto)

    float: (left 或 right)

    width: (任何值除了auto)

    zoom: (除 normal 外任意值)

    */

    </style>

    </head>

    <body>

    <div class="box clear">

    <div class="div"></div>

    </div>

    </body>

    </html>

    6.給浮動元素父級加overflow:auto;

    代碼如下:

    <!DOCTYPE HTML>

    <html>

    <head>

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

    <title>無標題文檔</title>

    <style>

    .box{ width:300px;border:1px solid #000;overflow:auto;}

    .div1{ width:260px;height:400px;background:Red;float:left;}

    </style>

    </head>

    <body>

    <div class="box">

    <div class="div1"></div>

    </div>

    </body>

    </html>

    更多信息請查看IT技術專欄

    更多信息請查看網(wǎng)頁制作
    易賢網(wǎng)手機網(wǎng)站地址:html清除浮動的幾種方法示例
    由于各方面情況的不斷調(diào)整與變化,易賢網(wǎng)提供的所有考試信息和咨詢回復僅供參考,敬請考生以權威部門公布的正式信息和咨詢?yōu)闇剩?/div>

    2026上岸·考公考編培訓報班

    • 報班類型
    • 姓名
    • 手機號
    • 驗證碼
    關于我們 | 聯(lián)系我們 | 人才招聘 | 網(wǎng)站聲明 | 網(wǎng)站幫助 | 非正式的簡要咨詢 | 簡要咨詢須知 | 新媒體/短視頻平臺 | 手機站點 | 投訴建議
    工業(yè)和信息化部備案號:滇ICP備2023014141號-1 云南省教育廳備案號:云教ICP備0901021 滇公網(wǎng)安備53010202001879號 人力資源服務許可證:(云)人服證字(2023)第0102001523號
    聯(lián)系電話:0871-65099533/13759567129 獲取招聘考試信息及咨詢關注公眾號:hfpxwx
    咨詢QQ:1093837350(9:00—18:00)版權所有:易賢網(wǎng)