標籤: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; }}