当前位置:  首页>> 技术小册>> Web响应式布局入门到实战

宽度,高度:

属性名称 作用
width、height 浏览器可视宽高
device-width 设备屏幕宽度
device-height 设备屏幕高度

浏览器宽度媒体查询:

  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  6. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  7. <title>Document</title>
  8. <style>
  9. div{
  10. width: 500px;
  11. height:200px;
  12. border:1px solid #ccc;
  13. }
  14. @media screen and (min-width:500px) and (max-width:700px){
  15. div{
  16. background-color: red;
  17. }
  18. }
  19. @media screen and (min-width:701px){
  20. div{
  21. background-color: blue;
  22. }
  23. }
  24. </style>
  25. </head>
  26. <body>
  27. <div>
  28. </div>
  29. </body>
  30. </html>

注意:
@media screen and 语法: and两边必须有空格。


该分类下的相关小册推荐: