響應式網站代碼收集整理

來源:互聯網
上載者:User

標籤:http   使用   width   html   for   代碼   

1、meta標籤大多數行動瀏覽器將HTML頁面放大為寬的視圖(viewport)以符合螢幕解析度。你可以使用視圖的meta標籤來進行重設。下面的視表徵圖簽告訴瀏覽器,使用裝置的寬度作為視圖寬度並禁止初始的縮放。在標籤裡加入這個meta標籤 <   meta name="viewport" content="width=device-width, initial-scale=1.0"   > IE8或者更早的瀏覽器並不支援Media Query。你可以使用media-queries.js或者respond.js來為IE添加Media Query支援 <   !--[if lt IE 9]>    <   script src="http://css3-mediaqueries-js.googlecode.com/svn/trunk/css3-mediaqueries.js"> <   ![endif]-->2、css 當視圖寬度為小於等於980像素時,如下規則將會生效。基本上,我會將所有的容器寬度從像素值設定為百分比以使得容器大小自適應。  /   * for 980px or less */@media screen and (max-width: 980px) {         #pagewarp {           width:94%;   }   #content {            width:65%;   }   #sidebar {           width:30%;   }    }         然後為小於等於700像素的視圖指定#content和#sidebar的寬度為自適應並且清除浮動,使得這些容器按全寬度顯示。  /   * for 700px or less */@media screen and (max-width: 700px) {         #content {             width:auto;             float:none;   }   #sidebar {            width:auto;            float:none;    }    }        對於小於等於480像素(手機螢幕)的情況,將#header元素的高度設定為自適應,將h1的字型大小修改為24像素並隱藏側邊欄。  /   * for 480px or less */@media screen and (max-width: 480px) {          #header {             height:auto;   }  h1 {            font-size:24px;    }   #sidebar {             display:none;    }}

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.