移動端開發基礎

來源:互聯網
上載者:User

標籤:style   blog   io   ar   color   使用   sp   strong   on   

1. viewport
屬性 說明
width 使用裝置獨立畫素表示所需的視區寬度。 它可以是明確的數字(如 240)或最好是相對值,如 device-width。
height 使用裝置獨立畫素表示所需的視區高度。 它可以是明確的數字(如 320)或最好是相對值,如 device-height。
initial-scale

表示首次載入頁面時所需的縮放層級。 值 1 表示應使用自然大小呈現頁面,根本不進行縮放。值 2 將頁面大小加倍,

依此類推。 您也可以使用十進位值,例如“1.0”。

minimum-scale 表示頁面允許的最低縮放層級。 值 1 表示使用者不能將頁面縮小到低於自然大小。
maximum-scale 表示頁面允許的最大縮放層級。 最大值為 10.0。
user-scalable yes/no 屬性,用於表示是否允許使用者縮放頁面。

常見用法:

<meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no">
 2. 媒體類型(media type)

常見用法:

<!--方法一 --><link href="style.css" media="screen"><!--方法二 -->@media screen{    selector{rules}}

另外,媒體類型支援notonly關鍵詞

@media only screen{      selector{rules}  }
3. 媒體查詢(media query)

文法結構:

1. @media 媒體類型 and (css屬性:值)

@media screen and (max-width:240px){    body{font-size:medium;}}

2. @media 媒體類型 and (css屬性:值), 媒體類型 and (css屬性:值)

@media handheld and (min-width:360px),screen and (min-width:480px){    body{font-size:large;}}
 4. 橫豎屏(landscape/portrait)
/*豎屏*/@media screen and (orientation:portrait) {    selector{rules}}/*橫屏*/@media screen and (orientation:landscape) {    selector{rules}}

 

移動端開發基礎

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.