Skip to content

[css] 第92天 移动端的布局用过媒体查询吗?写出例子看看 #903

Open
@haizhilin2013

Description

@haizhilin2013
Collaborator

第92天 移动端的布局用过媒体查询吗?写出例子看看

Activity

ghost

ghost commented on Jul 17, 2019

@ghost
@media [type] and [condition] … not [condition] {
    …
}
@media [condition] and/or/not [condition] … {
    …
}

其中:

type = "all" | "print" | "screen" | "speech"
condition = equality | comparison
equality = name ":" value
comparison = name ("<"|">")? "="? value
name = <CSS property name>
value = <CSS property value>
xiangshuo1992

xiangshuo1992 commented on Jul 17, 2019

@xiangshuo1992
Contributor

用媒体查询设置font-size实现适配,不过是老方法了,不算太好。

nowherebutup

nowherebutup commented on Jul 17, 2019

@nowherebutup
    body{
      height: 60vh;
    }
    @media(max-width:500px) {
      body{
        background-color: #000;
      }
    }
    @media(min-width:501px) and (max-width:900px) {
      body{
        background-color: #f00;
      }
    }
    @media(min-width:901px){
      body{
        background-color: #0f0;
      }
    }
NicholasBaiYa

NicholasBaiYa commented on Jul 17, 2019

@NicholasBaiYa

@media (max-width: 600px) { .facet_sidebar { display: none; } }

nobaidu

nobaidu commented on Jul 17, 2019

@nobaidu
    @media screen and (max-width:768px) {
        body {
            background: salmon;
        }
    }

    @media screen and (min-width:768px) {
        body {
            background: saddlebrown;
        }
    }

    @media screen and (min-width:992px) {
        body {
            background: gold;
        }
    }

    @media screen and (min-width:1200px) {
        body {
            background: pink;
        }
    }
wanghao1993

wanghao1993 commented on Jul 17, 2019

@wanghao1993

@media screen and (min-wdith: 1200px) {
body {background: red}
}
@media screen and (max-wdith: 1199px) and (min-wdith: 666px) {
body {background: fuck}
}

352056977gihub

352056977gihub commented on Jul 18, 2019

@352056977gihub

//根据像素比来使用 2x图 3x图
bg_image($star)
background-image:url('../images/stars/'+$star+'@2x.png')
@media only screen and (-webkit-device-pixel-ratio:3 )
background-image:url('../images/stars/'+$star+'@3x.png')

Konata9

Konata9 commented on Aug 21, 2019

@Konata9

在做 responsive 开发的时候有用到过 media query 来进行不同分辨率下适配。
在使用 bootstrap 栅格布局时,对于栅格范围外的情况就可能会需要微调。
平时对于屏幕大小的 media query 使用的频率最高。

@media(max-width: 768px){}
@media(min-width: 960px){}
@media(min-width: 768px) and (max-width: 960px){}
jamsehua

jamsehua commented on Jan 15, 2021

@jamsehua

@media print { ... }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @haizhilin2013@Konata9@nobaidu@xiangshuo1992@NicholasBaiYa

        Issue actions

          [css] 第92天 移动端的布局用过媒体查询吗?写出例子看看 · Issue #903 · haizlin/fe-interview