css響應式布局RWD

來源:互聯網
上載者:User

標籤:媒體查詢   效果   包含   百分比   style   color   rip   網路   sheet   

響應式布局結合了三大理念:

1)用於布局的彈性網路(百分比定義寬度)

2)用於圖片和視頻的彈性媒體

3)媒體查詢

在布局中,需要注意的點有:

1)盡量用min-width/max-width,max-height/min-height代替width,height

2)盡量使用百分比,em為單位代替精確值

3)採用媒體查詢

 

二、媒體查詢

IE8以下不支援媒體查詢,需要引入

<!-- if lte IE 8><script src="response.min.js"></script><![endif]-->

媒體查詢需要設定斷點,常見的斷點如480px,769px等。也可以逐漸縮小瀏覽器的寬度,觀察布局效果來引入。

媒體查詢引入的方式有兩種

1)通過link標籤引入

<link rel="stylesheet" href="css/small.css" media="(max-width:480x)"><link rel="stylesheet" href="css/large.css" media="(min-width:769x)"><link rel="stylesheet" href="css/large.css" media="(min-width:480px) and max-width(768px)">

2)將查詢包含在樣式表中

@media(max-width:480px){}@media(min-width:480px) and (max-width:768px){}@media(min-width:769px){}

 

css響應式布局RWD

聯繫我們

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