国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > HTML > 正文

實例介紹六種html清除浮動的方式,供參考

2020-03-24 19:08:55
字體:
來源:轉載
供稿:網友
使用display:inline-block會出現的情況:

1.使塊元素在一行顯示
2.使內嵌支持寬高
3.換行被解析了
4.不設置的時候寬度由內容撐開
5.在IE6,7下步支持塊標簽
由于inline-block屬性換行的時候被解析(有間隙)故解決方法使用浮動float:left/right
使用浮動時出現的情況:
1.使塊元素在一行顯示
2.使內嵌元素支持寬高
3.不設置不寬高的時候寬度由內容撐開
4.換行不被解析(故使用行內元素的時候清除間隙的方法可以使用浮動)
5.元素添加浮動,會脫離文檔流,按照指定的一個方向移動,直到碰到父級的邊界或者另一個浮動元素停止(文檔流是文檔中可顯示對象在排列時所占用的位置)

清浮動的方法:
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;}.p{ width:200px;height:200px;background:red;float:left;} 1.給父級也加浮動(不居中了) /style  /head  body  p >

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;}.p{ width:200px;height:200px;background:red;float:left;} 1.給父級也加浮動 2.給父級加display:inline-block /style  /head  body  p >

3.在浮動元素下加 p >
.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;}.p{ width:200px;height:200px;background:red;float:left;}.clear{ height:0px;font-size:0;clear:both;} 1.給父級也加浮動 2.給父級加display:inline-block 3.在浮動元素下加 p >

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;}.p{ width:200px;height:200px;background:red;float:left;} 1.給父級也加浮動 2.給父級加display:inline-block 3.在浮動元素下加 p >

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;}.p{ width:200px;height:200px;background:red;float:left;}.clear{zoom:1;}.clear:after{content: display:block;clear:both;} 1.給父級也加浮動 2.給父級加display:inline-block 3.在浮動元素下加 p >

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;}.p1{ width:260px;height:400px;background:Red;float:left;} /style  /head  body  p >

以上就是實例介紹六種html清除浮動的方式,供參考的詳細內容,html教程

鄭重聲明:本文版權歸原作者所有,轉載文章僅為傳播更多信息之目的,如作者信息標記有誤,請第一時間聯系我們修改或刪除,多謝。

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 浦北县| 虞城县| 色达县| 化州市| 阿荣旗| 宜州市| 涟水县| 银川市| 浦江县| 桂阳县| 宜兴市| 丹东市| 芮城县| 尚义县| 娄底市| 乌什县| 青阳县| 兴山县| 威宁| 大庆市| 昭平县| 儋州市| 高雄市| 轮台县| 丰镇市| 奇台县| 湖州市| 河津市| 昌宁县| 洛隆县| 米泉市| 昂仁县| 札达县| 大同县| 黎川县| 广宁县| 虹口区| 峨边| 建始县| 怀安县| 宁蒗|