zoukankan      html  css  js  c++  java
  • Bulma 中的媒体查询

    在 Bulma 中将设备分为 6 类:手机、平板、触屏设备、桌面、宽屏和大屏。提供了四个阈值。

    // sass/utilities/variables.sass
    
    $tablet: 769px !default
    $desktop: 1000px !default
    $widescreen: 1192px !default
    $fullhd: 1384px !default
    

    这些设备及对应设备宽度的范围如下:

    1. 手机:0px ~ 768px
    2. 平板:769px ~ 999px
    3. 触屏设备:0px ~ 999px
    4. 桌面:1000px ~ 1191px
    5. 宽屏:1192px ~ 1383px
    6. 大屏:1384px+

    我们使用混合定义设备的媒体查询。

    =from($device)
      @media screen and (min- $device)
        @content
    
    =until($device)
      @media screen and (max- $device - 1px)
        @content
    
    // 平板宽度以下的设备认为是手机设备
    =mobile
      @media screen and (max- $tablet - 1px)
        @content
    
    =tablet
      @media screen and (min- $tablet)
        @content
    
    // 仅在平板设备下
    =table-only
      @media screen and (min- $tablet) and  (max- $desktop - 1px)
        @content
    
    // 桌面宽度以下的设备认为是触屏设备
    =touch
      @media screen and (max- $desktop - 1px)
        @content
    
    =desktop
      @media screen and (min- $desktop)
        @content
    
    // 仅在桌面设备下
    =desktop-only
      @media screen and (min- $desktop) and (max- $widescreen - 1px)
        @content
    
    =widescreen
      @media screen and (min- $widescreen)
        @content
    
    // 仅在宽屏设备下
    =widescreen-only
      @media screen and (min- $widescreen) and (max- $fullhd - 1px)
        @content
    
    =fullhd
      @media screen and (min- $fullhd)
        @content
    

    接下来,如果要针对某个设备下进行样式编写,则可以这样使用。

    .container
      +desktop
        margin: 0 auto
         $desktop - 40px
    

    正如上面代码反映的一样,在桌面环境+的设备中,.container 的宽度固定为“$desktop - 40px”,也就是 960px,然后居中显示。

    (完)

  • 相关阅读:
    使用dig命令解析域名
    py安装以及配置pip环境变量
    JMeter中各种请求格式--aduocd的博客
    JMeter传递JSON数据
    idea中看不到项目结构该怎么办
    IntelliJ IDEA2018.1、2017.3激活
    postman--安装及Interceptor插件
    瑜伽体式缓解腰部不适
    SSM项目连接远程Linux服务器的mysql 启动tomcat卡在了 Initializing Spring root WebApplicationContext
    spring----AOP注解以及spring的JDBC和事务
  • 原文地址:https://www.cnblogs.com/zhangbao/p/6639805.html
Copyright © 2011-2022 走看看