java 記錄

          學習java

          萬能清除浮動樣式

          這個是一個很流行的清除浮動的方法,在很多大項目上已經被完全采用。
          這個方法來源于positioniseverything ,通過after偽類:after和IEhack來實現,完全兼容當前主流瀏覽器。

          <style type="text/css"> .clearfix:after { content: "."; display: block; height: 0; clear: both; visibility: hidden; } .clearfix {display: inline-block;}  /* for IE/Mac */   </style><!-- main stylesheet ends, CC with new stylesheet below... -->   <!--[if IE]> <style type="text/css"> .clearfix { zoom: 1;     /* triggers hasLayout */ <span style="color: #aa0000;">display: block;     /* resets display for IE/Win */</span> }  /* Only IE can see inside the conditional comment and read this CSS rule. Don't ever use a normal HTML comment inside the CC or it will close prematurely. */ </style> <![endif]-->

          Update @ 2008.11.12

          剛剛看到一篇日志說這個問題,受到了點啟發:

          .clearfix:after {     content: "020";     display: block;     height: 0;     clear: both; } .clearfix {     zoom: 1; }

          這個是優化版的清除浮動的樣式,很值得推薦。

          另外,我見到了一個無敵的清除浮動的樣式,這個是通過獨立的代碼來清除的。

          html body div.clear, html body span.clear {      background: none;      border: 0;      clear: both;      display: block;      float: none;      font-size: 0;      margin: 0;      padding: 0;      overflow: hidden;      visibility: hidden;      width: 0;      height: 0; }

          這個樣式可以通過在頁面中添加<div class=”clear”></div> 或 <span class=”clear”> </span>來清除頁面中的浮動。

          這個頁面正是著名的960 CSS 框架的作者的博客。而他卻在960 CSS框架中同時使用了這兩種方法。

          posted on 2011-08-26 14:31 啊飛 閱讀(80) 評論(0)  編輯  收藏 所屬分類: CSS


          只有注冊用戶登錄后才能發表評論。


          網站導航:
           
          <2025年6月>
          25262728293031
          1234567
          891011121314
          15161718192021
          22232425262728
          293012345

          導航

          統計

          常用鏈接

          留言簿(1)

          隨筆檔案

          文章分類

          文章檔案

          搜索

          最新評論

          主站蜘蛛池模板: 乳源| 紫云| 象山县| 嘉黎县| 都匀市| 平阳县| 长治市| 新建县| 南漳县| 开远市| 屏东市| 新乡市| 潞西市| 永福县| 延川县| 子长县| 辰溪县| 崇阳县| 濉溪县| 五莲县| 运城市| 洱源县| 博罗县| 云和县| 万全县| 长寿区| 化德县| 会泽县| 鄂尔多斯市| 望城县| 阿拉尔市| 马关县| 崇明县| 神农架林区| 罗源县| 南康市| 肥城市| 西峡县| 利川市| 衡南县| 株洲县|