隨筆-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 尨奇 閱讀(226) 評論(0)  編輯  收藏 所屬分類: CSS
          主站蜘蛛池模板: 遵化市| 新干县| 中卫市| 徐州市| 安福县| 丰原市| 岑溪市| 峨山| 蒙阴县| 绥阳县| 辽阳县| 调兵山市| 石渠县| 博湖县| 怀宁县| 普兰县| 陇西县| 色达县| 贵溪市| 望江县| 拜泉县| 赤城县| 拉孜县| 纳雍县| 杨浦区| 拉萨市| 长宁县| 上杭县| 阿坝| 垦利县| 鄯善县| 贵溪市| 凤冈县| 榆社县| 万安县| 尉氏县| 永兴县| 康定县| 马龙县| 日土县| 绥阳县|