媒体查询技术

1. 响应式网站

响应式是一种网页设计的技术做法,该设计可使网站在不同的设备上浏览时对应不同分辨率皆有适合的呈现

2. 媒体查询的判断条件

(1)媒体类型
all 所有媒体
screen 彩屏设备
print 打印机和打印预览
speech 应用于屏幕阅读器等发声设备

(2)媒体查询的逻辑关键词
and 和
not 非
only 限制某种媒体设备

(3)媒体查询的参数条件
(width:600px) 宽
(max-width:600px) 最大宽度
(min-width: 480px) 最小宽度
(orientation:portrait) 竖屏
(orientation:landscape) 横屏

3. 媒体查询方式

(1)方式一(内联样式)

        div {
            width: 100px;
            height: 100px;
            background-color: blue;
        }
        /* 当设备宽度在400到500之间时,div显示红色 */
        @media screen and (min-width: 400px) and (max-width: 500px) {
            div {
                background-color: red;
            }
        }

在这里插入图片描述

(2)方式二(外部样式)

    <link rel="stylesheet" href="css/index.css" media="screen and (min-width: 400px) and (max-width: 500px)">

        .box {
            width: 100px;
            height: 100px;
            background-color: blue;
        }
/* css/index.css */
div.box {
    background-color: red;
}

在这里插入图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值