css媒體查詢之width

語法

width:<length>
接受min/max前綴:是

取值

length:用長度值來定義寬度。不允許負值

用法說明

定義輸出設備中的頁面可見區域寬度。

  • 與盒模型width不同,媒體特性width的取值只能是。
  • 本特性接受min和max前綴,因此可以派生出min-width和max-width兩個媒體特性。

示例

<!doctype html>
<html>
    <head>
        <title>Media Query Test</title>
        <style>
            @media all and (min-width:500px) and (max-width:550px){
                body{
                    background-color:red;
                }
            } 
        </style>
    </head>
    <body>
        <div class="query"><h1>This is a test page</h1></div>
    </body>
</html>
  • 當屏幕寬度在500至550之間時候,該css樣式定義起作用,頁面背景顏色變爲紅色
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章