XinLake
V2EX  ›  问与答

问个 web 前端代码问题

  •  
  •   XinLake · Feb 10, 2018 · 1609 views
    This topic created in 3038 days ago, the information mentioned may be changed or developed.

    问题 1,下面这句话什么意思,赋的是什么值?

    mq-mobile = "screen and (max-width: 479px)"
    

    有多处地方用到 “ mq-mobile ” 如:

    #main-nav-toggle
      display: none
      &:before
        content: "\f0c9"
      @media mq-mobile
        display: block
    

    问题 2,如何去掉 “ mq-mobile ” ?
    是不是删除 @media mq-mobile 之后的代码就可以,如上方的代码去掉 mq-mobile:

    #main-nav-toggle
      display: none
      &:before
        content: "\f0c9"
    
    Supplement 1  ·  Feb 10, 2018
    补充一下,提问的目的是修改 Hexo,将手机浏览时左上的弹出式菜单去掉,和 desktop 浏览时一样。

    目前修改方式功能已实现(下面代码),但是不知道做法是否规范,怎么改才更加专业、规范?

    ```styl
    mq-mobile = "screen and (max-width: 1px)"
    ```
    3 replies    2018-02-10 16:00:46 +08:00
    learnshare
        1
    learnshare  
       Feb 10, 2018
    Vogan
        2
    Vogan  
       Feb 10, 2018
    这个变量是用来做媒体查询的,根据宽度使用不同的 css ;
    语法是 sass
    bayallen
        3
    bayallen  
       Feb 10, 2018 via iPhone
    没有大括号的,这是 stylus 吧。

    现在的前端项目很少直接写 CSS 了,都是用预处理器写,然后再编译成 CSS。

    这些预处理器会在 CSS 上添加一些编程语言里的功能,比如你问题里的 mq-mobile 就是变量,方便重用。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   831 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 35ms · UTC 21:22 · PVG 05:22 · LAX 14:22 · JFK 17:22
    ♥ Do have faith in what you're doing.