css响应式

响应式:适应不同的终端,在不同的 终端有较好的显示效果

媒体类型:

all 所有媒体

braille盲文触觉设备

embossed 盲文打印机

print 手持设备

Projection 打印预览

screen 彩屏设备

speech “听觉”类似的媒体类型

tty 不适用像素的设备

tv 电视

@media only只有在特定的某个设备上识别

and 连接媒体类型和媒体特性的

@media not 是用来排除某种特殊类型的 如@media not tv

@media(orientation:portrait)屏幕垂直

@media(orientation:landscape)屏幕水平

媒体特性:

     min-width 当屏幕大小大于等于某个值的时候识别

     max-width 当屏幕大小小于等于某个值的时候识别

具体代码:

<style>

        #box{

                width:100px;

                height:100px;

                background-color:red;

}

@media braille{

            #box{

                  background-color:green;

               } /*当盲文触觉设备上是绿色*/

}

@media tv{

           #box{

                 background-color:pink;

             } /*当tv设备上是粉色*/

         }

@media all{

           #box{

               background-color:red;

             } /*所有媒体上是红色*/

}

@media screen{

              #box{

                   background-color:pink;   

               }/*仅仅在彩色设备下识别*/

 

  }

@media all and (min-width:500px){

            #box{

                 background-color:green;   

               }/*当屏幕>=500的时候识别*/

 }

@media all and (max-width:500px){

           #box{

              background-color:yellow;

            }/*当屏幕<=500的时候识别*/

}

</style>

<div id="box">

</div>

 

响应式的引入方式一:

<link rel="stylesheet" href="01.css" media="all and (min-width:400px)" />

<link rel="stylesheet" href="02.css" media="all and (min-width:600px)" />

<link rel="stylesheet" href="03.css" media="all and (min-width:800px)" />

<link rel="stylesheet" href="04.css" media="all and (min-width:1000px)" />

响应式的引入方式二:

<style>

       @import url(01.css) (min-width:400px);

       @import url(02.css) (min-width:600px);

       @import url(03.css) (min-width:800px);

       @import url(04.css) (min-width:1000px);

</style>

 

文章来自:源码在线https://www.shengli.me/css/28.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值