隨筆-16  評論-0  文章-0  trackbacks-0

          在這章我們將學習到:

          1.盒子模式的復雜和特征
          2.怎樣并且為什么頁邊空白收縮
          3.絕對位置和相對位置的不同
          4.floating 和 clearing怎樣工作

          Box model recap

          * {
          margin: 0;
          padding: 0;
          }

          #myBox {
          margin: 10px;
          padding: 5px;
          width: 70px;
          }

          Margin collapsing





          Positioning recap

          Relative positioning 相對位置

          #myBox {
          position: relative;
          left: 20px;
          top: 20px;
          }

          Absolute positioning 絕對位置


          #branding {
          width: 700px;
          height: 100px;
          position: relative;
          }
          #branding .tel {
          position: absolute;
          right: 10px;
          bottom: 10px;
          text-align: right;
          }
          <div id="branding">
          <p class="tel">Tel: 0845 838 6163</p>
          </div>

          Floating




          Line boxes and clearing


          .news {
          background-color: gray;
          border: solid 1px black;
          }
          .news img {
          float: left;
          }
          .news p {
          float: right;
          }
          <div class="news">
          <img src="news-pic.jpg" />
          <p>Some text</p>
          </div>

           

          .news {
          background-color: gray;
          border: solid 1px black;
          }
          .news img {
          float: left;
          }
          .news p {
          float: right;
          }
          .clear {
          clear: both;
          }
          <div class="news">
          <img src="news-pic.jpg" />
          <p>Some text</p>
          <div class="clear"></div>
          </div>







          更簡捷的方法如下:

          .news {
          background-color: gray;
          border: solid 1px black;
          float: left;
          }
          .news img {
          float: left;
          }

          .news p {
          float: right;
          }
          <div class="news">
          <img src="news-pic.jpg" />
          <p>Some text</p>
          </div>

          posted on 2007-04-02 16:49 尨奇 閱讀(223) 評論(0)  編輯  收藏 所屬分類: CSS
          主站蜘蛛池模板: 商丘市| 高尔夫| 旌德县| 通城县| 齐齐哈尔市| 梁山县| 平昌县| 卓资县| 南平市| 长泰县| 南阳市| 乐业县| 新田县| 镇平县| 孝感市| 颍上县| 余干县| 武乡县| 大化| 民县| 新巴尔虎右旗| 阜平县| 宝鸡市| 河津市| 聂拉木县| 株洲市| 论坛| 宝山区| 龙里县| 滨海县| 弥勒县| 隆化县| 洮南市| 丹棱县| 隆林| 赞皇县| 五峰| 兴和县| 文安县| 逊克县| 土默特左旗|